简体   繁体   中英

BitmapImage Failing when trying to change image on a trigger c# UWP

I am trying to dynamically change the page I am on biased off of an event in a UWP application. When the even is triggered I check a simple if statement which passes and I try to set the old back ground image to a new one. I dumbed down my code to where I put the exact url (see image of file structure) in to where the image is located, but I still get an error. Bellow is the error:

Error: System.ArgumentException: 'Error 0x2624. Debugging resource strings are unavailable. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.30319.0&File=mscorrc.dll&Key=0x2624"

Here is The Affected Code:

c# -- MainPage.xmal.cs
BackGroundImage.Source = new BitmapImage(new Uri("/Assets/Images/Financial.png", UriKind.Relative));

XMAL --MainPage.xmal
<Image x:Name="BackGroundImage" Source="Assets/Images/Food.png" />

File Structure:

在此处输入图片说明

Whenever I trigger the even that changes the background I get the error and the program crashes. Does anyone have any idea why? This is my first time playing around with BitmapImages and Uri.

Well, please try to change the URL schemes.

Like the following:

BackGroundImage.Source= new BitmapImage(new Uri("ms-appx:///Assets/Images/Financial.png"));

For more details about URL schemes in UWP, please refer to this: URI schemes

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM