public static object OpenWindowDialog(UserControl control, WindowViewModelBase_VM dataContext, double width, double height, double minwidth, double minheight, Window owner = null)
        {
            object value  = null;
            var    window = GetWindow(control, dataContext, width, height, minwidth, minheight, owner, delegate(object obj) { value = obj; });

            window.ShowDialog();
            return(value);
        }
        public static Window GetWindow(UserControl control, WindowViewModelBase_VM dataContext, double width, double height, double minwidth, double minheight, Window owner, Action <object> Close = null)
        {
            var window = new Window();

            window.Width       = width;
            window.Height      = height;
            window.MinWidth    = minwidth;
            window.MinHeight   = minheight;
            window.Content     = control;
            window.DataContext = dataContext;
            window.Owner       = owner;

            Binding positionBinding = new Binding("Title")
            {
                Source = dataContext
            };

            window.SetBinding(Window.TitleProperty, positionBinding);

            CancelEventHandler delClose = (a, e) =>
            {
                e.Cancel = true;
                dataContext.CloseCommand.Execute(window);
                if (owner != null)
                {
                    owner.Activate();
                }
            };

            if (dataContext != null)
            {
                window.Closing += delClose;
                dataContext._attachedWindow = window;
                dataContext.CloseCommand    = new RelayCommand(delegate(object obj)
                {
                    window.Dispatcher.BeginInvoke(DispatcherPriority.Send, (Action)(() =>
                    {
                        if (dataContext.Closing(obj))
                        {
                            window.Closing -= delClose;
                            if (obj == window)
                            {
                                obj = null;
                            }
                            window.Close();
                            if (Close != null)
                            {
                                Close(obj);
                            }
                        }
                    }
                                                                                    ));
                });
            }
            System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(window);
            return(window);
        }
        public static void OpenWindow(UserControl control, WindowViewModelBase_VM dataContext, double width, double height, double minwidth, double minheight, Window owner = null)
        {
            var window = GetWindow(control, dataContext, width, height, minwidth, minheight, owner);

            window.Show();
        }