update pr/58
This commit is contained in:
1 parent
e9329ef982
commit
ce93f34467
8 files changed
+65
-112
No files matched your search
@@ -1,36 +1,30 @@
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using HandyControl.Tools.Extension;
|
||||
|
||||
namespace HandyControlDemo.ViewModel.Basic
|
||||
{
|
||||
public class InteractiveDialogViewModel : ViewModelBase, IDialogResultable
|
||||
public class InteractiveDialogViewModel : ViewModelBase, IDialogResultable<string>
|
||||
{
|
||||
public Action CloseAction { get; set; }
|
||||
|
||||
private string _result;
|
||||
|
||||
public string Result
|
||||
{
|
||||
get => _result;
|
||||
set => Set(ref _result, value);
|
||||
}
|
||||
|
||||
private string _message;
|
||||
|
||||
|
||||
public object Result { get; set; }
|
||||
|
||||
public Action ClosureToken { get; set; }
|
||||
|
||||
public ICommand CloseCommand { get; }
|
||||
|
||||
public string Message
|
||||
{
|
||||
get => _message;
|
||||
set => Set(ref _message, value);
|
||||
}
|
||||
|
||||
|
||||
public InteractiveDialogViewModel()
|
||||
{
|
||||
CloseCommand = new RelayCommand<string>(result =>
|
||||
{
|
||||
Result = result;
|
||||
ClosureToken();
|
||||
});
|
||||
}
|
||||
public RelayCommand CloseCmd => new Lazy<RelayCommand>(() => new RelayCommand(() => CloseAction?.Invoke())).Value;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
using System.Threading.Tasks;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using HandyControl.Controls;
|
||||
using HandyControl.Tools.Extension;
|
||||
using HandyControlDemo.Properties.Langs;
|
||||
using HandyControlDemo.UserControl;
|
||||
using HandyControlDemo.UserControl.Basic;
|
||||
using HandyControlDemo.ViewModel.Basic;
|
||||
@@ -15,32 +14,28 @@ namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
private string _dialogResult;
|
||||
|
||||
public RelayCommand ShowTextCmd => new Lazy<RelayCommand>(() =>
|
||||
new RelayCommand(ShowText)).Value;
|
||||
|
||||
public string DialogResult
|
||||
{
|
||||
get => _dialogResult;
|
||||
set => Set(ref _dialogResult, value);
|
||||
}
|
||||
|
||||
public ICommand ShowInteractiveDialogCmd { get; }
|
||||
|
||||
public DialogDemoViewModel()
|
||||
{
|
||||
DialogResult = Lang.PleaseInput;
|
||||
|
||||
ShowInteractiveDialogCmd = new RelayCommand<string>(async message =>
|
||||
{
|
||||
DialogResult = await Dialog.Show<InteractiveDialog>()
|
||||
.Initialize<InteractiveDialogViewModel>(vm => vm.Message = message)
|
||||
.GetResultAsync<string>();
|
||||
});
|
||||
}
|
||||
public RelayCommand ShowTextCmd => new Lazy<RelayCommand>(() =>
|
||||
new RelayCommand(ShowText)).Value;
|
||||
|
||||
private void ShowText()
|
||||
{
|
||||
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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Reflection.Emit;
|
||||
using System.Windows;
|
||||
using CommonServiceLocator;
|
||||
using GalaSoft.MvvmLight.Ioc;
|
||||
|
||||
Reference in new issue
Block a user