Skip to content

Commit 1a2d20b

Browse files
committed
add platform to the kb article
1 parent 572dcbf commit 1a2d20b

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

knowledge-base/change-telerik-theme-runtime.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ To ensure that the Telerik .NET MAUI controls respond to app theme changes corre
3333

3434
**1.** [Enable the Telerik Theming in your app]({%slug themes-overview%}#using-the-maui-theming).
3535

36-
**2.** Detect the current system theme—use the `Application.RequestedTheme` property to get the current `AppTheme` and load the light or dark mode of the Telerik Theme, for example:
36+
**2.** Detect the current system theme—use the `Application.RequestedTheme` property to get the current `AppTheme`.
37+
38+
**2.1** Example with loading the light or dark `Purple` swatch of the `Telerik` theme:
3739

3840
```C#
3941
private void ApplyTelerikTheme()
@@ -50,6 +52,23 @@ private void ApplyTelerikTheme()
5052
}
5153
```
5254

55+
**2.2** Example with loading the light or dark swatch of the `Platform` theme:
56+
57+
```C#
58+
private void ApplyTelerikTheme()
59+
{
60+
var telerikTheming = Application.Current
61+
.Resources
62+
.MergedDictionaries
63+
.OfType<TelerikTheming>()
64+
.Single();
65+
66+
var swatchName = Application.Current.RequestedTheme == AppTheme.Dark ? "Dark" : "Light";
67+
telerikTheming.Theme = TelerikTheming.Themes
68+
.Single(t => t.Theme == "Platform" && t.Swatch == swatchName);
69+
}
70+
```
71+
5372
For more details on the `Application.RequestedTheme` property, see the <a href="https://learn.microsoft.com/en-us/dotnet/maui/user-interface/system-theme-changes?view=net-maui-8.0#detect-the-current-system-theme" target="_blank">Detect the current system theme | MS Learn</a> topic.
5473

5574
**3.** Switch the Telerik theme to dark or light mode&mdash;use the `Application.RequestedThemeChanged` event to detect whenever the system theme has been changed and update the Telerik resources:

0 commit comments

Comments
 (0)