Created
May 25, 2022 13:53
-
-
Save Sandip124/18f7b6d69f194b438d8bc2b198162558 to your computer and use it in GitHub Desktop.
extension method to know windows has light mode or not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Determine whether it is a light theme | |
/// </summary> | |
/// <returns></returns> | |
/// <exception cref="InvalidOperationException"></exception> | |
public static bool IsLightTheme() | |
{ | |
using (var personalizeKey = | |
Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", | |
false)) | |
{ | |
return (int) (personalizeKey?.GetValue("SystemUsesLightTheme", 0) ?? 0) == 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment