@@ -18,21 +18,16 @@ namespace Core.ViewModel.Main;
1818/// </summary>
1919public partial class MainWindowViewModel : ObservableRecipient
2020{
21- public MainWindowViewModel ( )
22- {
23- WeakReferenceMessenger . Default . Register < MainWindowViewModel , PageChangeEventArgs > ( this , OnNavigation ) ;
24- }
21+ [ ObservableProperty ] private object ? _content ;
2522
2623 [ ObservableProperty ] private bool _settingPage = false ;
27- [ ObservableProperty ] private string _version = "0.0.2.128" ;
28- private void OnNavigation ( MainWindowViewModel recipient , PageChangeEventArgs message )
24+ [ ObservableProperty ] private string _version = "0.0.2.129" ;
25+
26+ public MainWindowViewModel ( )
2927 {
30- Content = message . Key ;
31- SettingPage = message . Key == "Setting" ;
28+ WeakReferenceMessenger . Default . Register < MainWindowViewModel , PageChangeEventArgs > ( this , OnNavigation ) ;
3229 }
3330
34- [ ObservableProperty ] private object ? _content ;
35-
3631 public ObservableCollection < MenuItemViewModel > MenuItems { get ; } = new ( )
3732 {
3833 new MenuItemViewModel
@@ -79,6 +74,12 @@ private void OnNavigation(MainWindowViewModel recipient, PageChangeEventArgs mes
7974 }
8075 } ;
8176
77+ private void OnNavigation ( MainWindowViewModel recipient , PageChangeEventArgs message )
78+ {
79+ Content = message . Key ;
80+ SettingPage = message . Key == "Setting" ;
81+ }
82+
8283 [ RelayCommand ]
8384 public void ActivateSettingPage ( )
8485 {
@@ -112,6 +113,15 @@ public PageChangeEventArgs(string key)
112113
113114public partial class MenuItemViewModel : ObservableObject
114115{
116+ [ ObservableProperty ] private bool _isSelected = false ;
117+
118+ public MenuItemViewModel ( )
119+ {
120+ WeakReferenceMessenger . Default . Register < PageChangeEventArgs > ( this ,
121+ ( recipient , message ) => { IsSelected = message . Key == Key ; } ) ;
122+ ActivateCommand = new RelayCommand ( OnActivate ) ;
123+ }
124+
115125 public string MenuHeader { get ; set ; }
116126 public string MenuIconGlyph { get ; set ; }
117127 public string MenuIconFilledGlyph { get ; set ; }
@@ -122,15 +132,6 @@ public partial class MenuItemViewModel : ObservableObject
122132 public ObservableCollection < MenuItemViewModel > Children { get ; set ; } = new ( ) ;
123133 public ICommand ActivateCommand { get ; set ; }
124134
125- [ ObservableProperty ] private bool _isSelected = false ;
126-
127- public MenuItemViewModel ( )
128- {
129- WeakReferenceMessenger . Default . Register < PageChangeEventArgs > ( this ,
130- ( recipient , message ) => { IsSelected = message . Key == Key ; } ) ;
131- ActivateCommand = new RelayCommand ( OnActivate ) ;
132- }
133-
134135 private void OnActivate ( )
135136 {
136137 if ( IsSeparator ) return ;
0 commit comments