Image source is not displayed
I have a problem setting the Image Source property ... So I tried all variations of this code and for some reason it won't work. When I set the property manually it works, but when I want to change the image in code it is just blank.
`BitmapImage` bm = new BitmapImage();
bm.UriSource=new Uri(this.BaseUri,@"\\Assets\logo6.png");
this.image.Source = image;
I am using this code inside the button event, so I can change the image inside the image control.
+3
source to share
1 answer
you are setting the path incorrectly. try either of these two, it will work.
Also make sure your image property Build Action is should set to Content
and Copy To OutPut Directory to Copy to newer
orCopy Always
BitmapImage bm = new BitmapImage();
bm.UriSource = new Uri(@"\Assets\Tiles\IconicTileSmall.png",UriKind.Relative);
image.Source = bm;
and
BitmapImage bm = new BitmapImage();
bm.UriSource = new Uri("\\Assets\\Tiles\\IconicTileSmall.png",UriKind.Relative);
image.Source = bm;
Basically, you mix the two.
+1
source to share