using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WpfApp29.Pages; namespace WpfApp29.ViewModels { internal class UserWindowViewModel { public UserWindowViewModel() { AppHelper.GetWindowAtType()?.FramePages.Navigate(MainPage); } private MainPage? _mainPage; private AccountPage? _accountPage; private UserListPage? _userListPage; public MainPage MainPage { get => _mainPage ??= new MainPage(); } public AccountPage AccountPage { get => _accountPage ??= new AccountPage(); } public UserListPage UserListPage { get => _userListPage ??= new UserListPage(); } public RelayCommand? _commandGoMainMenu; public RelayCommand CommandGoMainMenu { get { return _commandGoMainMenu ??= new RelayCommand( x => { AppHelper.GetWindowAtType()?.FramePages.Navigate(MainPage); }, x => { if (AppHelper.GetWindowAtType()?.FramePages.Content is MainPage) { return false; } return true; } ); } } public RelayCommand? _commandGoAccount; public RelayCommand CommandGoAccount { get { return _commandGoAccount ??= new RelayCommand( x => { AppHelper.GetWindowAtType()?.FramePages.Navigate(AccountPage); }, x => { if (AppHelper.GetWindowAtType()?.FramePages.Content is AccountPage) { return false; } return true; } ); } } public RelayCommand? _commandGoUserList; public RelayCommand CommandGoUserList { get { return _commandGoUserList ??= new RelayCommand( x => { AppHelper.GetWindowAtType()?.FramePages.Navigate(UserListPage); }, x => { if (AppHelper.GetWindowAtType()?.FramePages.Content is UserListPage) { return false; } return true; } ); } } public RelayCommand? _commandGoExit; public RelayCommand CommandGoExit { get { return _commandGoExit ??= new RelayCommand( x => { new MainWindow().Show(); AppHelper.GetWindowAtType()?.Close(); } ); } } } }