Navigation zwischen views Funktioniert
This commit is contained in:
@@ -11,14 +11,42 @@ namespace DaSaSo.ViewModel.State.ActualState
|
||||
public class ActualProject : IActualProject
|
||||
{
|
||||
public Client AktuellClient { get; private set; }
|
||||
|
||||
public Buildingsite AktuellBaustelle { get; private set; }
|
||||
public Project AktuellProjekt { get; private set; }
|
||||
|
||||
public Project AktuellProjekt { get; private set; }
|
||||
|
||||
#region events
|
||||
public event EventHandler? ClientChanged;
|
||||
public event EventHandler? ProjectChanged;
|
||||
public event EventHandler? BuildingSiteChanged;
|
||||
protected void OnClientChanged()
|
||||
{
|
||||
ClientChanged?.Invoke(this, new EventArgs());
|
||||
}
|
||||
protected void OnProjectChanged()
|
||||
{
|
||||
ProjectChanged?.Invoke(this, new EventArgs());
|
||||
}
|
||||
protected void OnBuildingSiteChanged()
|
||||
{
|
||||
BuildingSiteChanged?.Invoke(this, new EventArgs());
|
||||
}
|
||||
#endregion
|
||||
public void SetClient(Client client)
|
||||
{
|
||||
AktuellClient = client;
|
||||
OnClientChanged();
|
||||
}
|
||||
|
||||
public void SetProject(Project project)
|
||||
{
|
||||
AktuellProjekt = project;
|
||||
OnProjectChanged();
|
||||
}
|
||||
|
||||
public void SetBuildingSite(Buildingsite buildingsite)
|
||||
{
|
||||
AktuellBaustelle = buildingsite;
|
||||
OnBuildingSiteChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ using System.Windows.Input;
|
||||
|
||||
namespace DaSaSo.ViewModel.State.Navigation
|
||||
{
|
||||
public class Navigator : INavigator, INotifyPropertyChanged
|
||||
public class Navigator : ObservableObject, INavigator
|
||||
{
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
private BaseViewModel _currentViewModel;
|
||||
public BaseViewModel CurrentViewModel
|
||||
{
|
||||
@@ -19,17 +19,5 @@ namespace DaSaSo.ViewModel.State.Navigation
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand UpdateViewModelCommand { get; set; }
|
||||
|
||||
public Navigator(IViewModelAbstractFactory viewModelFactory)
|
||||
{
|
||||
UpdateViewModelCommand = new UpdateCurrentViewModelCommand(this, viewModelFactory);
|
||||
}
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName]string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using DaSaSo.ViewModel.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DaSaSo.ViewModel.State.Navigation
|
||||
{
|
||||
public class ViewModelFactoryRenavigator<TViewModel> : IRenavigator where TViewModel : BaseViewModel
|
||||
{
|
||||
private readonly INavigator _navigator;
|
||||
private readonly IViewModelFactory<TViewModel> _viewModelFactory;
|
||||
|
||||
public ViewModelFactoryRenavigator(INavigator navigator, IViewModelFactory<TViewModel> viewModelFactory)
|
||||
{
|
||||
_navigator = navigator;
|
||||
_viewModelFactory = viewModelFactory;
|
||||
}
|
||||
|
||||
public void Renavigate()
|
||||
{
|
||||
_navigator.CurrentViewModel = _viewModelFactory.CreateViewModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user