I have a class library project which I am using in a UWP project. If I add any usercontrol xaml file in the class library and build it it builds fine. But the UWP project gi
Yeah, for a class library with XAML files, if we want to reference the dll in other project, we need not only the dll itself but also the .xr.xaml file and some other files. Because in UWP environment, the resources are no longer embedded in the assembly but are placed next to the dll as content. See the similar case: How to add xbf files to visual studio project.
The files we need to reference like following:
- ClassLibrary1(Class Library name) Folder
- ClassLibrary1.xr.xml
- UserControl.xaml (UserControl XAML file)
- ClassLibrary1.dll
- ClassLibrary1.pri
To get these files, we can check the "Generate library layout" option in the Build configuration under the project's Properties page.
Then we can copy these files to anywhere and the UWP project just need to add reference to the ClassLibrary1.dll file in the Visual Studio, Visual Studio will automatically pick these files up and put them in the appx package when it builds the app.