【发布时间】:2015-02-09 06:22:57
【问题描述】:
如何在 Windows Phone 8 或 8.1 上将 png 项目文件加载到图像中?
【问题讨论】:
-
您的意思是如何将 .png 文件添加到 Assets 中以在应用中使用?
-
你尝试了什么?
标签: image windows-phone-8 windows-phone-8.1
如何在 Windows Phone 8 或 8.1 上将 png 项目文件加载到图像中?
【问题讨论】:
标签: image windows-phone-8 windows-phone-8.1
让我们在 XAML 文件中添加一个 Image,例如:
<Image Name="img"/>
现在,在代码文件中从 Assets 中分配其 source,例如:
img.Source = new BitmapImage { UriSource = new Uri("/Assets/text1.png", UriKind.Relative) };
就是这样。
【讨论】:
Flag.Source = new BitmapImage { UriSource = new Uri("ms-appx:///Flags/" + Flags.list[flagIndex].filename + ".png", UriKind.Absolute) };替换或相对URI,它就像一个魅力。非常感谢您回答如此原始的问题。