实现了导航功能
This commit is contained in:
6
ViewModels/DataTransformViewModel.cs
Normal file
6
ViewModels/DataTransformViewModel.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace PMSWPF.ViewModels;
|
||||
|
||||
public class DataTransformViewModel:ViewModelBase
|
||||
{
|
||||
|
||||
}
|
||||
6
ViewModels/DevicesViewModel.cs
Normal file
6
ViewModels/DevicesViewModel.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace PMSWPF.ViewModels;
|
||||
|
||||
public class DevicesViewModel:ViewModelBase
|
||||
{
|
||||
|
||||
}
|
||||
6
ViewModels/HomeViewModel.cs
Normal file
6
ViewModels/HomeViewModel.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace PMSWPF.ViewModels;
|
||||
|
||||
public class HomeViewModel:ViewModelBase
|
||||
{
|
||||
|
||||
}
|
||||
@@ -3,15 +3,30 @@ using CommunityToolkit.Mvvm.Messaging;
|
||||
using PMSWPF.Data.Entities;
|
||||
using PMSWPF.Message;
|
||||
using System.Collections.ObjectModel;
|
||||
using PMSWPF.Services;
|
||||
|
||||
namespace PMSWPF.ViewModels
|
||||
{
|
||||
partial class MainViewModel : ObservableRecipient, IRecipient<MyMessage>
|
||||
{
|
||||
|
||||
public MainViewModel()
|
||||
{
|
||||
private readonly NavgatorServices _navgatorServices;
|
||||
|
||||
[ObservableProperty]
|
||||
private ViewModelBase currentViewModel;
|
||||
public MainViewModel(NavgatorServices navgatorServices)
|
||||
{
|
||||
_navgatorServices = navgatorServices;
|
||||
_navgatorServices.OnViewModelChanged += () =>
|
||||
{
|
||||
CurrentViewModel = _navgatorServices.CurrentViewModel;
|
||||
};
|
||||
IsActive = true;
|
||||
CurrentViewModel = new HomeViewModel();
|
||||
}
|
||||
|
||||
public void NavgateTo<T>() where T : ViewModelBase
|
||||
{
|
||||
_navgatorServices.NavigateTo<T>();
|
||||
}
|
||||
|
||||
string text = "Hello Count:";
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using PMSWPF.Data.Entities;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace PMSWPF.ViewModels
|
||||
{
|
||||
public partial class PlcListViewModel : ObservableRecipient
|
||||
{
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<PLC> plcList;
|
||||
public PlcListViewModel()
|
||||
{
|
||||
plcList = new ObservableCollection<PLC>();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
6
ViewModels/ViewModelBase.cs
Normal file
6
ViewModels/ViewModelBase.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace PMSWPF.ViewModels;
|
||||
|
||||
public class ViewModelBase
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user