Files
DMS/DMS.WPF/ViewModels/Dialogs/DeviceDialogViewModel.cs

43 lines
923 B
C#
Raw Normal View History

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
2025-07-26 10:05:43 +08:00
using DMS.WPF.ViewModels.Items;
using System.Threading.Tasks;
2025-07-19 09:25:01 +08:00
namespace DMS.WPF.ViewModels.Dialogs;
public partial class DeviceDialogViewModel : DialogViewModelBase<DeviceItemViewModel>
{
2025-07-29 20:02:09 +08:00
[ObservableProperty]
private bool _isAddMode;
[ObservableProperty]
2025-07-26 10:05:43 +08:00
private DeviceItemViewModel _device;
2025-07-29 20:02:09 +08:00
public DeviceDialogViewModel(DeviceItemViewModel device=null)
{
2025-07-29 20:02:09 +08:00
if (device==null)
{
_device = new DeviceItemViewModel();
IsAddMode=true;
}
else
{
_device=device;
}
}
[RelayCommand]
private async Task Save()
{
// Here you can add validation logic before closing.
await Close(Device);
}
[RelayCommand]
private async Task Cancel()
{
await Close(null);
}
}