I'm using Windows.UI.ViewManagement.UISettings
to get system accent color but it seems this class does not have any method or property for light/dark mode. I failed to find a document for this feature, how can I detect this?
PS: I'm making a JS app which does not have access for Windows.UI.Xaml
namespace.
To enable dark mode, navigate to Settings > Personalization > Colors, then open the drop-down menu for "Choose your color" and pick Dark. Dark (and Light) mode change the look of the Windows Start menu and built-in apps. You can also decide to choose Custom if you want to mix and match color themes.
Select Start > Settings . Select Personalization > Colors. Under Choose your color, select Custom. Under Choose your default Windows mode, select Dark.
Click on Start > Cogwheel icon > Settings. Step 3: As you hit the Personalization option, a panel will open up on the left side of your computer screen. Click the “Colors” option. You will see three options: “Choose your color,” “Choose your default Window mode,” and “Choose your default app mode”.
You can create a Windows Runtime Component project in your solution from there you access Windows.UI.Xaml
namespace. Add a method to check current ApplicationTheme like that.
public sealed class Test
{
public static string CurrentTheme()
{
var isDark = Application.Current.RequestedTheme == ApplicationTheme.Dark;
if (isDark)
return "Dark";
return "Light";
}
}
Add reference to windows runtime component project in your javascript app project and you can call this method where ever you want to check application theme. Take a look here for walkthrough on createing Windows Runtime Component.
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