私は、すべてのモーダルスタイルのダイアログがUserControl
メインをカバーする半透明のグリッドの上に実装されるアプリケーション(c#+ wpf)を書いていますWindow
。これは、1つだけでありWindow
、すべての企業アプリケーションのルックアンドフィールを維持することを意味します。
を表示するMessageBox
ための構文は次のとおりです。
CustomMessageBox b = new CustomMessageBox("hello world");
c.DialogClosed += ()=>
{
// the rest of the function
}
// this raises an event listened for by the main window view model,
// displaying the message box and greying out the rest of the program.
base.ShowMessageBox(b);
ご覧のとおり、実行の流れが実際に逆転しているだけでなく、従来の.NETバージョンと比較してひどく冗長です。
MessageBox.Show("hello world");
// the rest of the function
私が本当に探しているのはbase.ShowMessageBox
、ダイアログを閉じるイベントが発生するまで戻らない方法ですが、GUIスレッドをハングさせて、ユーザーが[OK]をクリックするのを防ぐことなく、これを待つことができる方法がわかりません。デリゲート関数を関数のパラメーターとして使用して、ShowMessageBox
実行の反転を防ぐことができますが、それでもいくつかのクレイジーな構文/インデントが発生することは承知しています。
私は明らかな何かを見逃していますか、それともこれを行うための標準的な方法がありますか?