Missing xaml.xr of a class library file in UWP

我只是一个虾纸丫 提交于 2019-12-01 19:44:10
Jay Zuo

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.

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