75 lines
2.0 KiB
C#
75 lines
2.0 KiB
C#
using System;
|
|
using System.Windows.Input;
|
|
using Prism.Mvvm;
|
|
using Prism.Services.Dialogs;
|
|
using Telerik.Windows.Controls;
|
|
using DialogParameters = Prism.Services.Dialogs.DialogParameters;
|
|
|
|
namespace DI_Electrical.ViewModels
|
|
{
|
|
public class DialogTestViewModel : DialogBase, IDialogAware
|
|
{
|
|
#region binding
|
|
private string _parText;
|
|
/// <summary>
|
|
/// 参数值
|
|
/// </summary>
|
|
public string parText
|
|
{
|
|
get { return _parText; }
|
|
set { _parText = value; OnPropertyChanged(nameof(parText)); }
|
|
}
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 命令事件
|
|
/// </summary>
|
|
public ICommand Command_Close1 { get; set; }
|
|
/// <summary>
|
|
/// 命令事件
|
|
/// </summary>
|
|
public ICommand Command_Close2 { get; set; }
|
|
|
|
public DialogTestViewModel()
|
|
{
|
|
Command_Close1 = new DelegateCommand(onClose1);
|
|
Command_Close2 = new DelegateCommand(onClose2);
|
|
}
|
|
|
|
public string Title => "弹框测试页面";
|
|
|
|
public event Action<IDialogResult> RequestClose;
|
|
|
|
public bool CanCloseDialog()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public void OnDialogClosed()
|
|
{
|
|
|
|
}
|
|
|
|
public void OnDialogOpened(IDialogParameters parameters)
|
|
{
|
|
parText = parameters.GetValue<string>(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);
|
|
}
|
|
}
|
|
}
|