更新客户端渲染,更新了壳
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
|
||||
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
|
||||
// All Rights Reserved.
|
||||
|
||||
namespace Wpf.Ui.Demo.Mvvm.ViewModels;
|
||||
|
||||
public partial class SettingsViewModel : ViewModel
|
||||
{
|
||||
private bool _isInitialized = false;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _appVersion = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private Wpf.Ui.Appearance.ApplicationTheme _currentApplicationTheme = Wpf.Ui
|
||||
.Appearance
|
||||
.ApplicationTheme
|
||||
.Unknown;
|
||||
|
||||
public override void OnNavigatedTo()
|
||||
{
|
||||
if (!_isInitialized)
|
||||
{
|
||||
InitializeViewModel();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeViewModel()
|
||||
{
|
||||
CurrentApplicationTheme = Wpf.Ui.Appearance.ApplicationThemeManager.GetAppTheme();
|
||||
AppVersion = $"Wpf.Ui.Demo.Mvvm - {GetAssemblyVersion()}";
|
||||
|
||||
_isInitialized = true;
|
||||
}
|
||||
|
||||
private static string GetAssemblyVersion()
|
||||
{
|
||||
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString()
|
||||
?? string.Empty;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void OnChangeTheme(string parameter)
|
||||
{
|
||||
switch (parameter)
|
||||
{
|
||||
case "theme_light":
|
||||
if (CurrentApplicationTheme == Wpf.Ui.Appearance.ApplicationTheme.Light)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Wpf.Ui.Appearance.ApplicationThemeManager.Apply(Wpf.Ui.Appearance.ApplicationTheme.Light);
|
||||
CurrentApplicationTheme = Wpf.Ui.Appearance.ApplicationTheme.Light;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if (CurrentApplicationTheme == Wpf.Ui.Appearance.ApplicationTheme.Dark)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Wpf.Ui.Appearance.ApplicationThemeManager.Apply(Wpf.Ui.Appearance.ApplicationTheme.Dark);
|
||||
CurrentApplicationTheme = Wpf.Ui.Appearance.ApplicationTheme.Dark;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user