0

メインのViewModelとUserLoginViewModelがあります。ユーザービューモデルから、[OK]/[キャンセル]オプションを含むプロンプトを表示する必要があります。このリンク http://www.deanchalk.me.uk/post/WPF-MVVM-e28093-Simple-e28098MessageBoxShowe28099-With-Action-Func.aspxに記載されているように実行しました。無効なクロススレッドの例外を回避するために、ディスパッチャーを使用しました。コードはこのようなものです

  mainDispatcher.BeginInvoke(new MessageBoxDelegate
                  (
                      (message, title) => { Popup(msg, ""); }
                  ), messageArgs);

where mainDispatcher is the dispatcher of MainView and Popup is of type Func<string, string, MessageBoxResult>

And it works fine. The problem is that I cannot get the results from the BeginInvoke Method. Is there is any way to get the result from the BeginInvoke method? If is there is not, any suggestions how i can implement this?

4

2 に答える 2

2

MVVM モデルにどのように適合するかはわかりませんが、MessageBox の代わりにcode4fun のMessagePromptを使用することをお勧めします。

于 2012-06-26T07:55:47.257 に答える
0

明らかに、結果はvar result = Popup(msg, ""); で得られます。

BeginInvoke() の下のコードはすべて BeginInvoke() の前に実行されるため、BeginInvoke() 内で結果を評価する必要があります。

于 2012-06-28T09:34:44.420 に答える