https://github.com/andrewkeepcoding/switchingthemessampleapp
This is the source code from my YouTube video about switching themes on WinUI 3 app.
https://github.com/andrewkeepcoding/switchingthemessampleapp
Last synced: 11 months ago
JSON representation
This is the source code from my YouTube video about switching themes on WinUI 3 app.
- Host: GitHub
- URL: https://github.com/andrewkeepcoding/switchingthemessampleapp
- Owner: AndrewKeepCoding
- License: mit
- Created: 2022-04-09T13:20:32.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-06-13T13:33:05.000Z (over 1 year ago)
- Last Synced: 2025-01-07T17:41:49.960Z (about 1 year ago)
- Language: C#
- Homepage: https://youtu.be/w2XdbyNrXBQ
- Size: 19.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SwitchingThemesSampleApp
This is the source code from my YouTube video about switching themes on WinUI 3 app.
YouTube: https://youtu.be/w2XdbyNrXBQ
# Update
If you want to use a `ComboBox`:
```xaml
Default
Light
Dark
```
and in code-behind, get the `IThemeSelectorService`:
```cs
private readonly IThemeSelectorService _themeSelectorService = Ioc.Default.GetRequiredService();
```
and handle the `SelectionChanged` event:
```cs
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.FirstOrDefault() is not string themeName ||
Enum.TryParse(themeName, out var theme) is not true)
{
return;
}
_themeSelectorService.SetTheme(theme);
}
```