[英]How to reference an asset in class library in UWP with XAML syntax
I have a class library with a custom control in UWP. 我在UWP中有一个带有自定义控件的类库。 There is an asset image.png that is in the class library under the folder Assets
资产image.png位于文件夹Assets下的类库中
I want to display this image in the custom control using xaml syntax in generic.xaml inside the class library. 我想在类库中的generic.xaml中使用xaml语法在自定义控件中显示此图像。
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. 这花了我很长时间来解决,所以我发布了该主题的未来探索者的结果,因为我无法在任何地方找到一个好的解决方案。
Location of the files is: ClassLibraryName/Assets/image.scale-100.png ClassLibraryName/Assets/image.scale-150.png etc. 文件的位置是: ClassLibraryName / Assets / image.scale-100.png ClassLibraryName / Assets / image.scale-150.png等。
Build action: Content Copy to Output Directory: Do not Copy 构建操作: 内容复制到输出目录: 不复制
In generic.xaml I have this now and the image loads correctly: Image Source="../ClassLibraryName/Assets/image.png" 在generic.xaml中我现在有了这个并正确加载图像:Image Source =“../ ClassLibraryName / Assets / image.png”
It also works like this: Image Source="ms-appx:///ClassLibraryName/Assets/image.png" 它也是这样的:Image Source =“ms-appx:///ClassLibraryName/Assets/image.png”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.