Merge pull request #58 from DingpingZhang/enhance-dialog
添加“Dialog.ShowAsync<T>(): T”函数以获得Dialog的返回值
This commit is contained in:
13 files changed
+395
-161
No files matched your search
@@ -1,13 +1,25 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using HandyControl.Controls;
|
||||
using HandyControl.Tools.Extension;
|
||||
using HandyControlDemo.UserControl;
|
||||
using HandyControlDemo.UserControl.Basic;
|
||||
using HandyControlDemo.ViewModel.Basic;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
public class DialogDemoViewModel : ViewModelBase
|
||||
{
|
||||
private string _dialogResult;
|
||||
|
||||
public string DialogResult
|
||||
{
|
||||
get => _dialogResult;
|
||||
set => Set(ref _dialogResult, value);
|
||||
}
|
||||
|
||||
public RelayCommand ShowTextCmd => new Lazy<RelayCommand>(() =>
|
||||
new RelayCommand(ShowText)).Value;
|
||||
|
||||
@@ -15,5 +27,15 @@ namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
Dialog.Show(new TextDialog());
|
||||
}
|
||||
|
||||
public RelayCommand ShowInteractiveDialogCmd => new Lazy<RelayCommand>(() =>
|
||||
new RelayCommand(async () => await ShowInteractiveDialog())).Value;
|
||||
|
||||
private async Task ShowInteractiveDialog()
|
||||
{
|
||||
DialogResult = await Dialog.Show<InteractiveDialog>()
|
||||
.Initialize<InteractiveDialogViewModel>(vm => vm.Message = DialogResult)
|
||||
.GetResultAsync<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user