【问题标题】:How to load png project file into an image on Windows Phone 8?如何将 png 项目文件加载到 Windows Phone 8 上的图像中?
【发布时间】:2015-02-09 06:22:57
【问题描述】:

如何在 Windows Phone 8 或 8.1 上将 png 项目文件加载到图像中?

【问题讨论】:

  • 您的意思是如何将 .png 文件添加到 Assets 中以在应用中使用?
  • 你尝试了什么?

标签: image windows-phone-8 windows-phone-8.1


【解决方案1】:

让我们在 XAML 文件中添加一个 Image,例如:

        <Image Name="img"/>

现在,在代码文件中从 Assets 中分配其 source,例如:

        img.Source = new BitmapImage { UriSource = new Uri("/Assets/text1.png", UriKind.Relative) };

就是这样。

【讨论】:

  • “System.ArgumentException”类型的异常给定的 System.Uri 无法转换为 Windows.Foundation.Uri。
  • 用绝对的Flag.Source = new BitmapImage { UriSource = new Uri("ms-appx:///Flags/" + Flags.list[flagIndex].filename + ".png", UriKind.Absolute) };替换或相对URI,它就像一个魅力。非常感谢您回答如此原始的问题。
猜你喜欢
  • 2013-08-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-05
  • 1970-01-01
相关资源
最近更新 更多