Skip to content

Instantly share code, notes, and snippets.

@sthewissen
Created December 16, 2020 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sthewissen/ac1c78a9b3f87d140817e89efee3a830 to your computer and use it in GitHub Desktop.
Save sthewissen/ac1c78a9b3f87d140817e89efee3a830 to your computer and use it in GitHub Desktop.
ThemePickerViewModel
public class ThemePickerViewModel
{
public IList<AppThemeViewModel> AppThemes { get; set; } = new List<AppThemeViewModel> {
new AppThemeViewModel() { Key = (int)OSAppTheme.Unspecified },
new AppThemeViewModel() { Key = (int)OSAppTheme.Light },
new AppThemeViewModel() { Key = (int)OSAppTheme.Dark }
};
public ICommand SetAppThemeCommand { get; set; }
public ThemePickerViewModel()
{
SetAppThemeCommand = new Command<AppThemeViewModel>((x) => SetAppTheme(x));
}
void SetAppTheme(AppThemeViewModel theme)
{
Application.Current.UserAppTheme = (OSAppTheme)theme.Key;
Preferences.Set(Settings.AppTheme, theme.Key);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment