Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The Theme Listener class allows you to determine the current Application Theme, and when it is changed via System Theme changes.
Syntax
var Listener = new ThemeListener();
Listener.ThemeChanged += Listener_ThemeChanged;
private void Listener_ThemeChanged(ThemeListener sender)
{
var theme = sender.CurrentTheme;
// Use theme dependent code.
}
Dim listener = New ThemeListener()
AddHandler listener.ThemeChanged, AddressOf Listener_ThemeChanged
Private Sub Listener_ThemeChanged(ByVal sender As ThemeListener)
Dim theme = sender.CurrentTheme
' Use theme dependent code.
End Sub
Properties
| Property | Type | Description |
|---|---|---|
| CurrentTheme | ApplicationTheme | Gets or sets the Current Theme. |
| CurrentThemeName | string | Gets the Name of the Current Theme. |
| IsHighContrast | bool | Gets or sets a value indicating whether the current theme is high contrast. |
Events
| Events | Description |
|---|---|
| ThemeChanged | An event that fires if the Theme changes. |
Sample Project
Theme Listener Sample Page Source. You can see this in action in the Windows Community Toolkit Sample App.
Requirements
| Device family | Universal, 10.0.16299.0 or higher |
|---|---|
| Namespace | Microsoft.Toolkit.Uwp.UI |
| NuGet package | Microsoft.Toolkit.Uwp.UI |