[UWP]在UWP应用程序中合并来自引用程序集的XAML资源 [英] [UWP]Merging XAML resources from referenced assembly in UWP application

查看:67
本文介绍了[UWP]在UWP应用程序中合并来自引用程序集的XAML资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

H i,

我正在为Windows 10构建一个UWP应用程序。此应用程序是引用包含XAML资源的不同DLL程序集。

I am building a UWP application for Windows 10. This application is referencing different DLL assemblies which contains XAML resources.

在主应用程序中,我必须将程序集引用为DLL而不是项目。

In the main app, I have to reference the assemblies as a DLLs not as a Project.

如果我像项目一样引用程序集,那么我可以用以下内容引用资源:

If I reference the assemblies like a Project then I am able to reference the resource with:

" ms-appx:///assemblyname/resourcepath.xaml"。

"ms-appx:///assemblyname/resourcepath.xaml".

但是在项目的最后阶段,我只需要传播主要的UWP应用程序代码以及引用的DLL。

But in the final stage of the project I have to only circulate the main UWP application code along with the referenced DLLs.

如果我只是参考DLL然后上面的方法不起作用,vs抛出错误,说无法找到资源。

If I just reference the DLL then above method is not working, v.s. throws the error saying not able to find the resource.

我也试过了"pack://"但这也无效。

I also tried the "pack://" but this is also not working.

在汇编项目中,xaml属性设置为"Build Action:Page"。并复制到"输出目录:如果更新则复制"。我需要更改吗?

In the assembly project the xaml property is set as "Build Action : Page" and Copy to "Output Directory:Copy if newer". Do I need to change this?

如果有人知道,请告诉我完成此操作的方法。 

If anybody know please let me know the way to accomplish this. 

问候,

Vikas

Vikas

推荐答案

Hi Vikas Rayiparambil,

Hi Vikas Rayiparambil,

>>"我只是引用了DLL然后上面的方法无效"

>>" I just reference the DLL then above method is not working"

我做过一些测试,我发现它是由于XAML页面未包含在程序集中。因此,您可以按照以下步骤解决此问题。

I have done some tests, I found that it’s due to the XAML page wasn’t contained in the assembly. So you could follow my following steps to solve this issue.

1。右键单击"DLL"项目 - >选择属性 - >选择构建标记 - >输出(启用"生成库布局")

1. right click your "DLL" project -> select Properties -> select Build tag -> Output (enable the "Generate library layout")

2。转到输出路径,您将找到一个与程序集同名的文件夹

2. go to the Output path, you will find a folder with the same name as your assembly

3。将此文件夹复制到UWP主项目的根目录中(请注意,您需要在项目中包含".xaml"和".xml"文件)

3. copy this folder into your UWP main project’s root directory (please note that you need to include ".xaml" and ".xml" file in your project)

之后,它将解决您的问题。

After that, it would solve your problem.

最诚挚的问候,

Xavier Eoro

Xavier Eoro


这篇关于[UWP]在UWP应用程序中合并来自引用程序集的XAML资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆