implement NavigateCommand

This commit is contained in:
Natlinux81
2022-08-27 02:23:07 +02:00
parent 694b932f24
commit fa278fc245
15 changed files with 250 additions and 25 deletions

View File

@@ -0,0 +1,29 @@
using Apollon.WPF.Stores;
using Apollon.WPF.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Apollon.WPF.Commands
{
public class NavigatCommand<TViewModel> : CommandBase
where TViewModel : ViewModelBase
{
private readonly NavigationStore _navigationStore;
private readonly Func<TViewModel> _createViewModel;
public NavigatCommand(NavigationStore navigationStore, Func<TViewModel> createViewModel)
{
_navigationStore = navigationStore;
_createViewModel = createViewModel;
}
public override void Execute(object parameter)
{
_navigationStore.CurrentViewModel = _createViewModel();
}
}
}