我有一个主 ViewModel 和一个 UserLoginViewModel。从用户视图模型中,我需要显示带有确定/取消选项的提示。我已经按照此链接 http://www.deanchalk.me.uk/post/WPF-MVVM-e28093-Simple-e28098MessageBoxShowe28099-With-Action-Func.aspx中的说明完成了它。为了避免无效的跨线程异常,我使用了调度程序。代码是这样的
mainDispatcher.BeginInvoke(new MessageBoxDelegate
(
(message, title) => { Popup(msg, ""); }
), messageArgs);
其中 mainDispatcher 是 MainView 的调度程序,而 Popup 是类型 Func<string, string, MessageBoxResult>
它工作正常。问题是我无法从BeginInvoke
方法中获得结果。有没有办法从BeginInvoke
方法中得到结果?如果没有,有什么建议我可以如何实现?