0
votes

I have UWP application and I want to retrieve the Power and Sleep setting information and display it to the UI.

For example: On Windows settings, I set the Sleep timer to Never Power and Sleep setting in Windows setting

Then when I open my UWP application and go to Power setting UI, it will reflect the selected settings in the dropdown list.

My question now is, Is it possible to control (Read, Update) the Power and Sleep setting in Windows 10 thru C# programming. If yes, Any Tips on how to Achieve this feature in my App that I can Change and Display the Sleep settings to the application UI.

Any suggestion or comments are appreciated.

1
For now, there's no built-in APIs for you to do it. You could submit a Feature Request on WPDev UserVoice. - Xie Steven

1 Answers

0
votes

I can not find any api to change it but you can send the user to setting page to set the power.

 await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:powersleep")); 

If you want your app run without off screen like a video app that you can use this code.

        var displayRequest = new DisplayRequest();
        displayRequest.RequestRelease();

See: Launch the Windows Settings app - UWP app developer