实现了导航功能
This commit is contained in:
29
Services/NavgatorServices.cs
Normal file
29
Services/NavgatorServices.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PMSWPF.ViewModels;
|
||||
|
||||
namespace PMSWPF.Services;
|
||||
|
||||
public class NavgatorServices
|
||||
{
|
||||
private ViewModelBase currentViewModel;
|
||||
|
||||
public ViewModelBase CurrentViewModel
|
||||
{
|
||||
get { return currentViewModel; }
|
||||
set
|
||||
{
|
||||
currentViewModel = value;
|
||||
OnViewModelChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public event Action OnViewModelChanged ;
|
||||
|
||||
public void NavigateTo<T>() where T : ViewModelBase
|
||||
{
|
||||
// Application.Current
|
||||
CurrentViewModel = App.Current.Services.GetService<T>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user