修改了CopyTo方法,使用反射可以将列表的内容也可以复制
This commit is contained in:
@@ -23,6 +23,6 @@ public partial class DeviceDialogViewModel : ObservableObject
|
||||
[RelayCommand]
|
||||
public void AddDevice()
|
||||
{
|
||||
device.CopyTo<Device>(_saveDevice);
|
||||
device.CopyTo(_saveDevice);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System.Collections.ObjectModel;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using PMSWPF.Data.Entities;
|
||||
using PMSWPF.Data.Repositories;
|
||||
using PMSWPF.Services;
|
||||
|
||||
namespace PMSWPF.ViewModels;
|
||||
@@ -8,16 +11,22 @@ public partial class MainViewModel : ViewModelBase
|
||||
private readonly NavgatorServices _navgatorServices;
|
||||
|
||||
[ObservableProperty] private ViewModelBase currentViewModel;
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<DbMenu> _menus;
|
||||
|
||||
public MainViewModel(NavgatorServices navgatorServices)
|
||||
{
|
||||
_navgatorServices = navgatorServices;
|
||||
_navgatorServices.OnViewModelChanged += () => { CurrentViewModel = _navgatorServices.CurrentViewModel; };
|
||||
CurrentViewModel = new HomeViewModel();
|
||||
CurrentViewModel.OnLoaded();
|
||||
}
|
||||
|
||||
|
||||
public override void OnLoaded()
|
||||
public override async void OnLoaded()
|
||||
{
|
||||
MenuRepositories mr = new MenuRepositories();
|
||||
var menuList= await mr.GetMenu();
|
||||
Menus=new ObservableCollection<DbMenu>(menuList);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user