예제 #1
0
        /// <summary>
        /// Closes current open modal.
        /// </summary>
        public static void Close()
        {
            if (!_open)
            {
                return;
            }

            Dispatcher.UIThread.Post(() => ModalAttacher.Detach(ModalView));
            _open = false;
        }
예제 #2
0
        /// <summary>
        /// Shows the modal to the main window.
        /// </summary>
        /// <param name="title">Modal title.</param>
        /// <param name="content">Modal content.</param>
        /// <param name="buttons">Modal buttons to be shown.</param>
        /// <returns>Modal dialog result.</returns>
        public static async Task <ModalResult> Show(string title, object content, ModalButtons buttons)
        {
            await WaitForClose();

            _open = true;
            SetUpViewModel(title, content, buttons);

            await Dispatcher.UIThread.InvokeAsync(async() =>
            {
                ModalAttacher.Attach(ModalView);
                await WaitForClose();
            });

            return(((IModalViewModel)ModalView.DataContext).CurrentResult);
        }