0

I'm creating a windows store app and was wondering how to change the image source using C# I have included the following directive;

using Windows.UI.Xaml.Media.Imaging;

and this is the line I have to try and change the image

cloud.Source = new BitmapImage(new Uri("Assets/cloud1.png", UriKind.Relative));

cloud is the name of the image tag and cloud1 is the source I want to change it to.. but it gives me this error...

"The given System.Uri cannot be converted into a Windows.Foundation.Uri"

Any help appreciated! thanks in advance

1 Answer 1

1

Use

cloud.Source = new BitmapImage(new Uri("ms-appx:/Assets/cloud1.png", UriKind.Relative));

instead.

Sign up to request clarification or add additional context in comments.

2 Comments

I had to change "UriKind.Relative" to "UriKind.RelativeOrAbsolute" but with the inclusion of ms-appx it worked! thanks, how come that worked? what did it actually do?
Take a look at this and this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.