XamlParseException when using UserControl from class library dll

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

When I create a new universal Windows application and create the same UserControl inside the application and open a popup, it will open.

But if I create a class library and create the same UserControl inside it and try to use it (by opening a popup window) inside the application, I get a XamlParseException.

It looks like this:

Windows.UI.Xaml.Markup.XamlParseException event occurred
HResult = -2144665590
Error Message = XAML.
Source = Windows
Stacktrace:
on Windows.UI.Xaml.Application.LoadComponent (object component, Uri resourceLocator, ComponentResourceLocation componentResourceLocation)
in PopupTestLibrary.MyUserControl1.InitializeComponent ()

I can’t understand exactly why this is happening, since the code works fine when not being called from an external class library.

Some questions I found similar to mine here on SO are

XamlParseException when using a page from a library

Unable to create UserControl instance from another assembly

All help is appreciated!

+1
windows-8 windows-10 windows-store-apps uwp
source share
2 answers

You need to add a resource dictionary to your application and add Usercontrol Xaml content to it

since Xaml is considered as a content file not compiled into code

0
source share
+1
source share

All Articles