implement NavigateCommand
This commit is contained in:
@@ -9,25 +9,38 @@ namespace Apollon.WPF.ViewModels
|
||||
{
|
||||
public class MainViewModel : ViewModelBase
|
||||
{
|
||||
private readonly NavigationStore _navigationStore;
|
||||
private readonly ModalNavigationStore _modalNavigationStore;
|
||||
|
||||
public ViewModelBase CurrentModalViewModel => _modalNavigationStore.CurrentViewModel;
|
||||
public ViewModelBase CurrentViewModel => _navigationStore.CurrentViewModel;
|
||||
public bool IsModalOpen => _modalNavigationStore.IsOpen;
|
||||
public OverviewViewModel OverviewViewModel { get; }
|
||||
|
||||
|
||||
public MainViewModel(ModalNavigationStore modalNavigationStore, OverviewViewModel overviewViewModel)
|
||||
public MainViewModel(ModalNavigationStore modalNavigationStore, OverviewViewModel overviewViewModel, NavigationStore navigationStore)
|
||||
{
|
||||
_navigationStore = navigationStore;
|
||||
_modalNavigationStore = modalNavigationStore;
|
||||
OverviewViewModel = overviewViewModel;
|
||||
|
||||
|
||||
_modalNavigationStore.CurrentViewModelChanged += ModalNavigationStore_CurrentViewModelChanged;
|
||||
_navigationStore.CurrentViewModelChanged += NavigationStore_CurrentViewModelChanged;
|
||||
_modalNavigationStore.CurrentViewModelChanged += ModalNavigationStore_CurrentViewModelChanged;
|
||||
|
||||
}
|
||||
|
||||
protected override void Dispose()
|
||||
{
|
||||
_navigationStore.CurrentViewModelChanged -= NavigationStore_CurrentViewModelChanged;
|
||||
_modalNavigationStore.CurrentViewModelChanged -= ModalNavigationStore_CurrentViewModelChanged;
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
private void NavigationStore_CurrentViewModelChanged()
|
||||
{
|
||||
OnPropertyChanged(nameof(CurrentViewModel));
|
||||
}
|
||||
private void ModalNavigationStore_CurrentViewModelChanged()
|
||||
{
|
||||
OnPropertyChanged(nameof(CurrentModalViewModel));
|
||||
|
||||
16
Apollon.WPF/ViewModels/NavBarViewModel.cs
Normal file
16
Apollon.WPF/ViewModels/NavBarViewModel.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Apollon.WPF.Stores;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Apollon.WPF.ViewModels
|
||||
{
|
||||
public class NavBarViewModel : ViewModelBase
|
||||
{
|
||||
public NavBarViewModel(NavigationStore navigationStore)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,14 +15,17 @@ namespace Apollon.WPF.ViewModels
|
||||
public OverviewListingViewModel OverviewListingViewModel { get; }
|
||||
public OverviewDetailsViewModel OverviewDetailsViewModel{ get; }
|
||||
|
||||
public ICommand AddTournamentCommand { get; }
|
||||
public ICommand AddTournamentCommand { get; }
|
||||
public ICommand NavigateNavBarCommand { get; }
|
||||
|
||||
public OverviewViewModel(TournamentsStore tournamentStore, SelectedTournamentsStore selectedTournamentStore, ModalNavigationStore modalNavigationStore)
|
||||
public OverviewViewModel(TournamentsStore tournamentStore, SelectedTournamentsStore selectedTournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore)
|
||||
{
|
||||
OverviewListingViewModel = OverviewListingViewModel.LoadViewModel(selectedTournamentStore, modalNavigationStore, tournamentStore);
|
||||
OverviewDetailsViewModel = new OverviewDetailsViewModel(selectedTournamentStore);
|
||||
|
||||
AddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore);
|
||||
AddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore);
|
||||
NavigateNavBarCommand = new NavigatCommand<NavBarViewModel>(navigationStore, () => new NavBarViewModel(navigationStore));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user