I have a model with property as BitmapImage and I am trying to load and image from root -> Assets -> Icons folder and set it to this property . But always gives me the error "Invalid URI: The format of the URI could not be determined." We originally created this project in WP8.0 and then targeted it to 8.1
BitmapImage bi = new BitmapImage();
bi.UriSource = new Uri(@"../Assets/Icons/noprofilepic.png", UriKind.RelativeOrAbsolute);
bi.CreateOptions = BitmapCreateOptions.BackgroundCreation;
BuddyImage = bi;
Property is defined as :
private BitmapImage _BuddyImage;
public BitmapImage BuddyImage
{
get { return _BuddyImage; }
set { _BuddyImage = value; RaisePropertyChanged("BuddyImage"); }
}
xaml control looks like below
<Image Source="{Binding BuddyImage}" Width="75" Height="75" Stretch="Uniform"/>
使用ms-appx:///例如:
bi.UriSource = new Uri("ms-appx:///Assets/Icons/noprofilepic.png");
objBitmapImage.UriSource = new Uri("ms-appx:///Assets/Logo.scale-240.png");
This will work. First Check whether you are able to display images without binding.If not check the build action property of the particular image is set as "Content".
我发现以下对我来说很好用:
new Uri("Assets/Icons/noprofilepic.png", UriKind.Relative)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.