Пример #1
0
        protected virtual Task <bool> ShowWindow(FrameworkElement element, MvxWindowPresentationAttribute attribute, MvxViewModelRequest request)
        {
            Window window;

            if (element is IMvxWindow mvxWindow)
            {
                window = (Window)element;
                mvxWindow.Identifier = attribute.Identifier ?? element.GetType().Name;
            }
            else if (element is Window normalWindow)
            {
                // Accept normal Window class
                window = normalWindow;
            }
            else
            {
                // Wrap in window
                window = new MvxWindow
                {
                    Identifier = attribute.Identifier ?? element.GetType().Name
                };
            }
            window.Closed += Window_Closed;
            FrameworkElementsDictionary.Add(window, new Stack <FrameworkElement>());

            if (!(element is Window))
            {
                FrameworkElementsDictionary[window].Push(element);
                window.Content = element;
            }

            if (attribute.Modal)
            {
                window.ShowDialog();
            }
            else
            {
                window.Show();
            }
            return(Task.FromResult(true));
        }
Пример #2
0
        protected virtual Task <bool> ShowModalWindow(FrameworkElement element, ModalPresentationAttribute attribute, MvxViewModelRequest request)
        {
            Window window;

            if (element is IMvxWindow mvxWindow)
            {
                window = (Window)element;
                mvxWindow.Identifier = element.GetType().Name;
            }
            else if (element is Window normalWindow)
            {
                // Accept normal Window class
                window = normalWindow;
            }
            else
            {
                // Wrap in window
                window = new MvxWindow
                {
                    Identifier = element.GetType().Name
                };
            }
            window.Closed += Window_Closed;
            FrameworkElementsDictionary.Add(window, new Stack <FrameworkElement>());

            if (!(element is Window))
            {
                FrameworkElementsDictionary[window].Push(element);
                window.Content = element;
            }

            ContentControl owner = FrameworkElementsDictionary.Keys.FirstOrDefault(c => c.GetType() == attribute.OwnerWindowType);

            if (owner != default)
            {
                window.Owner = (Window)owner;
            }

            window.ShowDialog();
            return(Task.FromResult(true));
        }
Пример #3
0
        protected virtual void ShowWindow(FrameworkElement element, MvxWindowPresentationAttribute attribute, MvxViewModelRequest request)
        {
            Window window;

            if (element is MvxWindow)
            {
                window = (Window)element;
                ((MvxWindow)window).Identifier = attribute.Identifier ?? element.GetType().Name;
            }
            else if (element is Window)
            {
                // Accept normal Window class
                window = (Window)element;
            }
            else
            {
                // Wrap in window
                window = new MvxWindow
                {
                    Identifier = attribute.Identifier ?? element.GetType().Name
                };
            }
            window.Closed += Window_Closed;
            _frameworkElementsDictionary.Add(window, new Stack <FrameworkElement>());

            if (!(element is Window))
            {
                _frameworkElementsDictionary[window].Push(element);
                window.Content = element;
            }

            if (attribute.Modal)
            {
                window.ShowDialog();
            }
            else
            {
                window.Show();
            }
        }