-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1330 from unoplatform/dev/doti/systemthemehelper-…
…page docs: Add `SystemThemeHelper` page
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
uid: Toolkit.Helpers.SystemThemeHelper | ||
--- | ||
|
||
# SystemThemeHelper | ||
|
||
Provides utilities for managing and retrieving the current theme of the operating system and the application. | ||
|
||
## Theme Retrieval | ||
|
||
### Methods | ||
|
||
| Method | Return Type | Description | | ||
|------------------------------|-------------------------|---------------------------------------------------------------------------------------------------------------| | ||
| `GetCurrentOsTheme()` | `ApplicationTheme` | Retrieves the current theme of the operating system. | | ||
| `GetApplicationTheme()` | `ApplicationTheme` | **[Obsolete]** Retrieves the current theme of the application. Will be removed in future versions. | | ||
| `GetRootTheme(XamlRoot?)` | `ApplicationTheme` | Gets the `ApplicationTheme` of the provided `XamlRoot`, or falls back to the operating system theme. | | ||
| `IsAppInDarkMode()` | `bool` | **[Obsolete]** Returns `true` if the application is currently in dark mode, otherwise `false`. | | ||
| `IsRootInDarkMode(XamlRoot)` | `bool` | Determines if the provided `XamlRoot` is in dark mode. | | ||
|
||
### Usage | ||
|
||
Example of retrieving the current OS theme: | ||
|
||
```csharp | ||
var osTheme = SystemThemeHelper.GetCurrentOsTheme(); | ||
Console.WriteLine($"Current OS Theme: {osTheme}"); | ||
``` | ||
|
||
Retrieve the application theme: | ||
|
||
```csharp | ||
var xamlRoot = someElement.XamlRoot; | ||
var appTheme = SystemThemeHelper.GetRootTheme(xamlRoot); | ||
Console.WriteLine($"Current App Theme: {appTheme}"); | ||
``` | ||
|
||
## Theme Management | ||
|
||
### Methods | ||
|
||
| Method | Description | | ||
|-------------------------------------|----------------------------------------------------------------------------------------------| | ||
| `SetApplicationTheme(bool)` | **[Obsolete]** Sets the application theme to dark mode if `darkMode` is `true`, otherwise light mode. Will be removed in future versions. | | ||
| `SetRootTheme(XamlRoot?, bool)` | Sets the theme for the provided `XamlRoot` based on the `darkMode` parameter. | | ||
| `SetApplicationTheme(XamlRoot?, ElementTheme)` | Sets the `ElementTheme` (`Light` or `Dark`) for the provided `XamlRoot`. | | ||
| `ToggleApplicationTheme()` | **[Obsolete]** Toggles the application theme between light and dark modes. Will be removed in future versions. | | ||
|
||
### Usage | ||
|
||
Set the theme for a specific `XamlRoot`: | ||
|
||
```csharp | ||
var xamlRoot = someElement.XamlRoot; | ||
SystemThemeHelper.SetApplicationTheme(xamlRoot, ElementTheme.Light); | ||
Console.WriteLine("XamlRoot theme set to Light Mode."); | ||
``` |
This file contains 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