XamlParseException when using UserControl from class library dll

我们两清 提交于 2019-12-13 01:04:01

问题


I have created a library which has a Popup UserControl similar to the one here.

When I create a fresh Universal Windows App and create the same UserControl inside an app and open the popup, it opens.

But if I create a Class Library and create the same UserControl inside it and try to use it (by opening the popup) inside an app, I get a XamlParseException.

It is as follows -

Windows.UI.Xaml.Markup.XamlParseException occurred
HResult=-2144665590
Message=XAML parsing failed.
Source=Windows
StackTrace:
at Windows.UI.Xaml.Application.LoadComponent(Object component, Uri resourceLocator, ComponentResourceLocation componentResourceLocation)
at PopupTestLibrary.MyUserControl1.InitializeComponent()

I am not able to understand exactly why this is happening, since the code works fine when not called from an external class library.

Some Questions I found to be similar to mine, here on SO -

XamlParseException when consuming a Page from a library

Cannot instantiate UserControl from another assembly

All help is appreciated!


回答1:


You need to Add a Resource Dictionary in your App and Add the Usercontrol Xaml content to it

as Xaml is Considered as a Content file not compiled into the code




回答2:


I think that this post is just as yours.. :

https://social.msdn.microsoft.com/Forums/en-US/63f071be-a3c5-4f2d-ace2-73ca750e3252/rtm-usercontrol-class-library-and-assembly-name-with-

And, It's known issue:

Dot in the project's name cause XAMLParseException

I hope that this will help you in your issue..



来源:https://stackoverflow.com/questions/34150168/xamlparseexception-when-using-usercontrol-from-class-library-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!