| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Prism.Commands;
- using Prism.Interactivity.InteractionRequest;
- using Prism.Mvvm;
- using Prism.Services.Dialogs;
- namespace OHV.Module.Interactivity
- {
- public class ConfirmationPopupViewModel : BindableBase, IDialogAware
- {
- private DelegateCommand<string> _closeDialogCommand;
- public DelegateCommand<string> CloseDialogCommand =>
- _closeDialogCommand ?? (_closeDialogCommand = new DelegateCommand<string>(CloseDialog));
- private string _message;
- public string Message
- {
- get { return _message; }
- set { SetProperty(ref _message, value); }
- }
- private string _title = "Notification";
- public string Title
- {
- get { return _title; }
- set { SetProperty(ref _title, value); }
- }
- public event Action<IDialogResult> RequestClose;
- public ConfirmationPopupViewModel()
- {
- }
- protected virtual void CloseDialog(string parameter)
- {
- ButtonResult result = ButtonResult.None;
- if (parameter?.ToLower() == "true")
- result = ButtonResult.OK;
- else if (parameter?.ToLower() == "false")
- result = ButtonResult.Cancel;
- RaiseRequestClose(new DialogResult(result));
- }
- public virtual void RaiseRequestClose(IDialogResult dialogResult)
- {
- RequestClose?.Invoke(dialogResult);
- }
- public bool CanCloseDialog()
- {
- return true;
- }
- public void OnDialogClosed()
- {
- }
- public void OnDialogOpened(IDialogParameters parameters)
- {
- Message = parameters.GetValue<string>("message");
- }
- }
- }
|