![](/img/trans.png)
[英]How to export a file from the Assets folder to the phone's Documents folder in Windows Phone 8.1 RT?
[英]How to get image from assets folder in windows phone 8.1 and assign it to a model's property
我有一个模型,其属性为BitmapImage,我试图从root-> Assets-> Icons文件夹加载图像并设置为该属性。 但是总是给我错误“无效的URI:无法确定URI的格式”。 我们最初是在WP8.0中创建此项目,然后将其定位到8.1
BitmapImage bi = new BitmapImage();
bi.UriSource = new Uri(@"../Assets/Icons/noprofilepic.png", UriKind.RelativeOrAbsolute);
bi.CreateOptions = BitmapCreateOptions.BackgroundCreation;
BuddyImage = bi;
属性定义为:
private BitmapImage _BuddyImage;
public BitmapImage BuddyImage
{
get { return _BuddyImage; }
set { _BuddyImage = value; RaisePropertyChanged("BuddyImage"); }
}
xaml控件如下所示
<Image Source="{Binding BuddyImage}" Width="75" Height="75" Stretch="Uniform"/>
使用ms-appx:///例如:
bi.UriSource = new Uri("ms-appx:///Assets/Icons/noprofilepic.png");
objBitmapImage.UriSource =新的Uri(“ ms-appx:///Assets/Logo.scale-240.png”);
这将起作用。 首先,检查是否能够显示没有绑定的图像。如果未选中,则将特定图像的构建操作属性设置为“内容”。
我发现以下对我来说很好用:
new Uri("Assets/Icons/noprofilepic.png", UriKind.Relative)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.