コード例 #1
0
ファイル: Modal.cs プロジェクト: ag-csharp/Modalonia
        /// <summary>
        /// Closes current open modal.
        /// </summary>
        public static void Close()
        {
            if (!_open)
            {
                return;
            }

            Dispatcher.UIThread.Post(() => ModalAttacher.Detach(ModalView));
            _open = false;
        }
コード例 #2
0
ファイル: Modal.cs プロジェクト: ag-csharp/Modalonia
        /// <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);
        }