pw94
pw94

Reputation: 401

Change image source in Windows 8

In XAML I have an image: <Image x:Name="Tlo" Margin="0,0,10,11" Source="Images/detail_bg.png" Stretch="Fill"/> I'd like to change image to another after taping on one button. Inside body of function which handles this event there is a code to change image:

 Tlo.Source = new BitmapImage(new Uri("/Images/detail_bgp.png", UriKind.Relative));

When I was running an application I had been getting exception:

An exception of type 'System.ArgumentException' occurred in mscorlib.dll but was not handled in user code

Additional information: Podana klasy System.Uri nie można przekształcić na klasę Windows.Foundation.Uri. Aby uzyskać więcej informacji, zobacz http://go.microsoft.com/fwlink/?LinkID=215849.
Then part in Polish of additional information means something like: Class System.Uri can't be process into class Windows.Fundation.Uri

Upvotes: 1

Views: 1873

Answers (1)

It&#39;sNotALie.
It&#39;sNotALie.

Reputation: 22794

What you need to do is use an absolute URI, as the link suggests:

Tlo.Source = new BitmapImage(new Uri("ms-appx:///Images/detail_bgp.png", UriKind.Absolute));

If that doesn't work replace ms-appx with ms-appx-web.

Upvotes: 3

Related Questions