Created
December 16, 2020 12:16
-
-
Save sthewissen/ac1c78a9b3f87d140817e89efee3a830 to your computer and use it in GitHub Desktop.
ThemePickerViewModel
This file contains hidden or 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
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