JavaAndCSharp
JavaAndCSharp

Reputation: 1557

Images' sources mysteriously don't change

I have a XAML page with lots of images. When a textBlock is loaded, the images' sources are supposed to change. This mysterious problem only started happening recently.

I have no clue why the images are not being changed. The code executes without error, no warnings are displayed, and everything else executes flawlessly - except for the images' sources changing.

If I tap a button to change one image's source at a time, the one image that was told to change changes; but when the page is loaded, the images don't change, and simply display the default placeholder image.

I've managed to work around this by navigating to a blank page and back to the page with the images. When I do that, the images are loaded - but that's caused further issues with the Back button.

Why are these images not changing and how can I make them change without the above kludgey fix?

Upvotes: 0

Views: 117

Answers (2)

JavaAndCSharp
JavaAndCSharp

Reputation: 1557

Apparently, I had a chunk of code that checked for a value in IsolatedStorage. For some strange reason, that value in IsolatedStorage was only updated on the press of the "Load" button.

Thus, nothing I would've tried would work. Thanks to @odyodyodys for suggesting to have my controls invalidate. This caused me to look at my image-changing code which let me see the problem.

That's why I'm going to give him the enter image description here.

Again, the only problem here is user error {me}.

Upvotes: 0

Odys
Odys

Reputation: 9090

This is probably because your image files are either too big in size, are distributed in other machines/internet, or your phone has many open applications or debug files. This can result in difficulties while getting the content.

When the UI tries to render, it fails to load images on time and it does render with whats available.

To solve this you can try reducing image size, have images available near the executable (if you are getting them from an online location), or clean some space/close some apps.

If all the above fail, you can always force your controls to Invalidate. This will make them re-call their render method. This will solve your problem, although is not the best solution.

Upvotes: 1

Related Questions