public ModalDialogContext(string title = null)
        {
            var             activeView = new SerialDisposable();
            ModalDialogView dialog     = null;        // new ModalDialogView();
            var             dispatcher = Application.Current.Dispatcher;

            //var dispatcher = dialog.Dispatcher;
            dispatcher.BeginInvoke(() => {
                dialog = new ModalDialogView();
                if (!disposables.IsDisposed)
                {
                    disposables.Add(
                        Disposable.Create(
                            () => dispatcher.BeginInvoke(
                                () => dialog.Close()
                                )
                            )
                        );
                    dialog.Header = title;
                    dialog.Owner  = Application.Current.MainWindow;
                    dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                    dialog.SizeToContent         = SizeToContent.WidthAndHeight;
                    dialog.ShowInTaskbar         = false;
                    dialog.ShowDialog();
                    activeView.Dispose();
                }
            });
            var presenter = ViewPresenter.Create(view => {
                var disp = new CompositeDisposable();
                activeView.Disposable = disp;
                dispatcher.BeginInvoke(() => {
                    dbg.Assert(dialog != null);
                    if (!disp.IsDisposed)
                    {
                        dbg.Assert(dialog.Content == null);
                        dialog.Content = view;
                        var header     = NavigationContext.GetTitle(view);
                        dialog.Header  = header ?? title;
                        disp.Add(Disposable.Create(() => {
                            dispatcher.BeginInvoke(() => {
                                dbg.Assert(dialog.Content == view);
                                dialog.Header  = title;
                                dialog.Content = null;
                                var d          = view as IDisposable;
                                if (d != null)
                                {
                                    d.Dispose();
                                }
                            });
                        }));
                    }
                });
                return(disp);
            });

            container.RegisterInstance <IViewPresenter>(presenter);
        }
		public ModalDialogContext(string title = null) {
			var activeView = new SerialDisposable();
			ModalDialogView dialog = null;// new ModalDialogView();
			var dispatcher = Application.Current.Dispatcher;
			//var dispatcher = dialog.Dispatcher;
			dispatcher.BeginInvoke(() => {
				dialog = new ModalDialogView();
				if (!disposables.IsDisposed) {
					disposables.Add(
						Disposable.Create(
							() => dispatcher.BeginInvoke(
								()=>dialog.Close()
							)
						)
					);
					dialog.Header = title;
					dialog.Owner = Application.Current.MainWindow;
					dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
					dialog.SizeToContent = SizeToContent.WidthAndHeight;
					dialog.ShowInTaskbar = false;
					dialog.ShowDialog();
					activeView.Dispose();
				}
			});
			var presenter = ViewPresenter.Create(view => {
				var disp = new CompositeDisposable();
				activeView.Disposable = disp;
				dispatcher.BeginInvoke(()=>{
					dbg.Assert(dialog != null);
					if (!disp.IsDisposed) {
						dbg.Assert(dialog.Content == null);
						dialog.Content = view;
						var header = NavigationContext.GetTitle(view);
						dialog.Header = header ?? title;
						disp.Add( Disposable.Create(() => {
							dispatcher.BeginInvoke(() => {
								dbg.Assert(dialog.Content == view);
								dialog.Header = title;
								dialog.Content = null;
								var d = view as IDisposable;
								if (d != null) {
									d.Dispose();
								}
							});
						}));
					}
				});
				return disp;
			});
			container.RegisterInstance<IViewPresenter>(presenter);
		}