如何使用XAML语法在UWP中的类库中引用资产 [英] How to reference an asset in class library in UWP with XAML syntax

查看:47
本文介绍了如何使用XAML语法在UWP中的类库中引用资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有UWP中的自定义控件的类库.在类库中的文件夹资产

I have a class library with a custom control in UWP. There is an asset image.png that is in the class library under the folder Assets

我想使用类库中generic.xaml中的xaml语法在自定义控件中显示此图像.

I want to display this image in the custom control using xaml syntax in generic.xaml inside the class library.

推荐答案

这花了我很多时间来解决,所以我将结果发布给该主题的未来探索者,因为我没有设法在任何地方找到好的解决方案

That took me quite a while to solve, so I am posting the outcome for future explorers of the topic since I didn't manage to find a good solution anywhere.

文件的位置是: ClassLibraryName/Assets/image.scale-100.pngClassLibraryName/Assets/image.scale-150.png

构建操作:内容复制到输出目录:请勿复制

Build action: Content Copy to Output Directory: Do not Copy

在generic.xaml中,我现在有了这个并且图像正确加载:图片来源="../ClassLibraryName/Assets/image.png"

In generic.xaml I have this now and the image loads correctly: Image Source="../ClassLibraryName/Assets/image.png"

它也像这样工作:图片来源="ms-appx:///ClassLibraryName/Assets/image.png"

It also works like this: Image Source="ms-appx:///ClassLibraryName/Assets/image.png"

这篇关于如何使用XAML语法在UWP中的类库中引用资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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