using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using DMS.WPF.ViewModels.Items; using System.Threading.Tasks; namespace DMS.WPF.ViewModels.Dialogs; public partial class DeviceDialogViewModel : DialogViewModelBase { [ObservableProperty] private bool _isAddMode; [ObservableProperty] private DeviceItemViewModel _device; public DeviceDialogViewModel(DeviceItemViewModel device=null) { 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); } }