Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows 10 Sleep Issue. Graphics disappearing

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?

SystemEvents not found

like image 291
Joris Weimar Avatar asked Sep 02 '15 20:09

Joris Weimar


People also ask

How do I fix a black Screen on Windows 10 after sleeping?

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.

Why my PC goes to sleep even though settings are never?

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.


2 Answers

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.

like image 184
Anas Avatar answered Sep 22 '22 00:09

Anas


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.

like image 21
Joris Weimar Avatar answered Sep 19 '22 00:09

Joris Weimar