Add a InteractiveDialog demo for the DialogExtension.
This commit is contained in:
1 parent
70d4a39e3b
commit
e9329ef982
11 files changed
+338
-159
No files matched your search
@@ -0,0 +1,36 @@
|
||||
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
|
||||
{
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,43 @@
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
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;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
public class DialogDemoViewModel : ViewModelBase
|
||||
{
|
||||
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>();
|
||||
});
|
||||
}
|
||||
|
||||
private void ShowText()
|
||||
{
|
||||
Dialog.Show(new TextDialog());
|
||||
|
||||
@@ -5,6 +5,7 @@ using CommonServiceLocator;
|
||||
using GalaSoft.MvvmLight.Ioc;
|
||||
using HandyControlDemo.Data;
|
||||
using HandyControlDemo.Service;
|
||||
using HandyControlDemo.ViewModel.Basic;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
@@ -30,6 +31,7 @@ namespace HandyControlDemo.ViewModel
|
||||
SimpleIoc.Default.Register<DialogDemoViewModel>();
|
||||
SimpleIoc.Default.Register<SearchBarDemoViewModel>();
|
||||
SimpleIoc.Default.Register<NotifyIconDemoViewModel>();
|
||||
SimpleIoc.Default.Register<InteractiveDialogViewModel>();
|
||||
}
|
||||
|
||||
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
|
||||
@@ -65,6 +67,7 @@ namespace HandyControlDemo.ViewModel
|
||||
|
||||
public NotifyIconDemoViewModel NotifyIconDemo => ServiceLocator.Current.GetInstance<NotifyIconDemoViewModel>();
|
||||
|
||||
public InteractiveDialogViewModel InteractiveDialog => ServiceLocator.Current.GetInstance<InteractiveDialogViewModel>();
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user