Пример #1
0
        //this works fine but best to keep ContainerWindow
        //public bool ShowDialogView_Window_test(IDialog vm)
        //{
        //    DialogContainer dc = new DialogContainer();
        //    Window w = new Window();
        //    //var titleBinding = new Binding("DialogTitle");
        //    w.SetBinding(Window.TitleProperty,new Binding("DialogTitle"));
        //    w.SizeToContent = SizeToContent.WidthAndHeight;
        //    w.WindowStartupLocation = WindowStartupLocation.CenterScreen;
        //    w.WindowStyle = WindowStyle.ToolWindow;
        //    w.ResizeMode = ResizeMode.CanResizeWithGrip;
        //    w.Owner = _wpfWindow;
        //    w.DataContext = vm;
        //    w.Content = dc;
        //    w.CommandBindings.Add(new CommandBinding(vm.DialogAcceptCommand, (sender, e) => w.DialogResult = true));
        //    return w.ShowDialog().GetValueOrDefault(false);
        //}


        public MessageBoxResultEnum ShowMessageBox(string title, string message, MessageBoxButtonEnum buttons)
        {
            var b = (MessageBoxButton)buttons;
            //var r = MessageBox.Show(message, title, b);
            MessageBoxResult r;

            r = _wpfWindow.Dispatcher.Invoke(() =>
                                             MessageBox.Show(_wpfWindow, message, title, b, MessageBoxImage.Exclamation)
                                             );
            return((MessageBoxResultEnum)r);
        }
Пример #2
0
        public void ShowDialog(object view,string title, Action<bool> result, MessageBoxButtonEnum buttons)
        {
            if (result == null)
                result = new Action<bool>((o) => { });

            MessageBoxButton button = MessageBoxButton.OKCancel;
            switch (buttons)
            {
                case MessageBoxButtonEnum.OK:
                    button = MessageBoxButton.OK;
                    break;
                case MessageBoxButtonEnum.OkCancel:
                    button = MessageBoxButton.OKCancel;
                    break;
                case MessageBoxButtonEnum.YesNo:
                    button = MessageBoxButton.YesNo;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("buttons");
            }
            Application.Current.Dispatcher.BeginInvoke(
                new Action(() => result(ZeroMessageBox.Show(view, title, button).GetValueOrDefault())));
        }
Пример #3
0
 //this works fine but best to keep ContainerWindow
 //public bool ShowDialogView_Window_test(IDialog vm)
 //{
 //    DialogContainer dc = new DialogContainer();
 //    Window w = new Window();
 //    //var titleBinding = new Binding("DialogTitle");
 //    w.SetBinding(Window.TitleProperty,new Binding("DialogTitle"));
 //    w.SizeToContent = SizeToContent.WidthAndHeight;
 //    w.WindowStartupLocation = WindowStartupLocation.CenterScreen;
 //    w.WindowStyle = WindowStyle.ToolWindow;
 //    w.ResizeMode = ResizeMode.CanResizeWithGrip;
 //    w.Owner = _wpfWindow;
 //    w.DataContext = vm;
 //    w.Content = dc;
 //    w.CommandBindings.Add(new CommandBinding(vm.DialogAcceptCommand, (sender, e) => w.DialogResult = true));
 //    return w.ShowDialog().GetValueOrDefault(false);
 //}
 public MessageBoxResultEnum ShowMessageBox(string title, string message, MessageBoxButtonEnum buttons)
 {
     var b = (MessageBoxButton)buttons;
     //var r = MessageBox.Show(message, title, b);
     MessageBoxResult r;
     r = _wpfWindow.Dispatcher.Invoke(() =>
             MessageBox.Show(_wpfWindow, message, title, b, MessageBoxImage.Exclamation)
             );
     return (MessageBoxResultEnum)r;
 }