using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using System; using System.Collections.Generic; using System.Linq; using System.Reflection.Metadata; using System.Text; using System.Threading.Tasks; using System.Windows; namespace WPFWCSDemo.ViewModels.CustomComponent { public partial class InputDialogViewModel : ObservableObject { public InputDialogViewModel(Window window,Action action) { Caption = "验证"; InputDialog = window; _task = action; } /// /// 标题 /// [ObservableProperty] string _caption; /// /// 内容 /// [ObservableProperty] string _content; /// /// 当前页面 /// [ObservableProperty] Window _inputDialog; [ObservableProperty] Action? _task; /// /// 关闭窗口 /// /// [RelayCommand] void Cancel(Window window) { window.Close(); } /// /// 输入密码 /// [RelayCommand] void Accept(string taskId) { if (Content == "472") { MessageBox.Show("密码正确"); //Task.Invoke(taskId); } else { MessageBox.Show("密码错误"); } } } }