[英]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.