public MessageBoxWindow(MessageBoxInfo options)
            : base()
        {
            InitializeComponent();

            Loaded += MessageBoxWindow_Loaded;

            DataContext = new MessageBoxViewModel(options, result =>
            {
                MessageBoxResult = result;
                CloseModal();
            });
        }
        public MessageBoxViewModel(MessageBoxInfo info, Action<MessageBoxResult> closeAction)
        {
            _closeAction = closeAction;

            Caption = info.Caption;
            Text = info.Text;
            Button = info.Button;
            Icon = info.Icon;
            TimeoutMs = info.TimeoutMs;

            YesCommand = new RelayCommand(i => Close(MessageBoxResult.Yes));
            NoCommand = new RelayCommand(i => Close(MessageBoxResult.No));
            OKCommand = new RelayCommand(i => Close(MessageBoxResult.OK));
            CancelCommand = new RelayCommand(i => Close(MessageBoxResult.Cancel));
        }
        /// <summary>
        /// Shows the message.
        /// </summary>
        /// <param name="options">The options.</param>
        /// <param name="parentWindow">The parent window.</param>
        /// <returns>MessageBoxResult.</returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public MessageBoxResult ShowMessage(MessageBoxInfo options, Window parentWindow)
        {
            return parentWindow.Dispatcher.Invoke(() =>
            {
                var win = new MessageBoxWindow(options);

                win.ShowModal(parentWindow);

                return win.MessageBoxResult;
            });
        }
 /// <summary>
 /// Shows the message.
 /// </summary>
 /// <param name="options">The options.</param>
 /// <returns>MessageBoxResult.</returns>
 public MessageBoxResult ShowMessage(MessageBoxInfo options)
 {
     return ShowMessage(options, Window);
 }
Пример #5
0
 public MessageBoxResult ShowMessage(MessageBoxInfo options)
 {
     return _themeManager.DefaultTheme.ShowMessage(options);
 }