An open API service indexing awesome lists of open source software.

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.

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);
}
```