I have a Windows UWP C#/XAML app that has a strange issue. When the display goes to sleep and I wake the computer up, some button graphics disappear. I have a Windows 8 app that exhibits the same behavior on Windows 10, but not on Windows 8. I want to try to build a workaround that refreshes UI elements upon waking from a sleep but I'm having a hard time finding a trigger. I've heard about this PowerModeChanged event but I cannot find this API somehow. Any ideas?
Go to the Power Option and change the sleep mode settings to "Never" in relation to the options "Turn off hard disk" and "Sleep after". Tap on "Power buttons and lid". Finish off by changing it to sleep. You can also rollback the drivers.
In addition to the Power Settings, check at Settings > Personalization > Lock Screen > Screen Saver Settings are set to None as some Themes may set a 1 minute blank timeout.
If the API is not available you could try to refresh the UI based on mouse/keyboard activity after being idle for certain time, if that works, you need to have the idle equal to time needed for computer to sleep, another you could also try is catching the activated event on your own app in case it fires after sleep.
I just wanted to add the answer that relates to the original problem in my question: the disappearing of the graphics.
I had multiple Image elements with that had the same Source URI (pointing to same image). One of them was hidden, the other one wasn't. Somehow this caused the images to disappear altogether. Must be something about how XAML handles referencing Images especially after a suspend/awake. I added ?1 to one of the image URI's and the problem was resolved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With