using System; using System.Threading; using System.Threading.Tasks; using System.Windows.Input; using Prism.Services.Dialogs; using SWS.Commons; using Telerik.Windows.Controls; using DialogParameters = Prism.Services.Dialogs.DialogParameters; namespace SWS.WPF.ViewModels { public class DialogTestViewModel : DialogBase, IDialogAware { private string _parText; /// /// 参数值 /// public string parText { get { return _parText; } set { _parText = value; OnPropertyChanged(nameof(parText)); } } /// /// 命令事件 /// public ICommand Command_Close1 { get; set; } /// /// 命令事件 /// public ICommand Command_Close2 { get; set; } public DialogTestViewModel() { Command_Close1 = new DelegateCommand(onClose1); Command_Close2 = new DelegateCommand(onClose2); title = "弹框测试页面"; } public string Title => "弹框测试页面"; public event Action RequestClose; public bool CanCloseDialog() { return true; } public void OnDialogClosed() { } public void OnDialogOpened(IDialogParameters parameters) { parText = parameters.GetValue(GlobalObject.dialogPar.para1.ToString()); } public void onClose1(object o) { IDialogParameters par = new DialogParameters(); par.Add(GlobalObject.dialogPar.para1.ToString(), "xxx"); DialogResult result = new DialogResult(ButtonResult.Yes, par); RequestClose.Invoke(result); } public void onClose2(object o) { IDialogParameters par = new DialogParameters(); par.Add(GlobalObject.dialogPar.para1.ToString(), "zzz"); DialogResult result = new DialogResult(ButtonResult.No, par); RequestClose.Invoke(result); } } }