0
我在Windows Phone上有一个异步调用的页面,我想从中显示一个MessageBox。我通常会:如何使用C#离子WP7中的静态方法显示MessageBox?
this.Dispatcher.BeginInvoke(() => MessageBox.Show("The message"));
但这并不完全适用于静态方法。
如何从静态方法显示MessageBox?
我在Windows Phone上有一个异步调用的页面,我想从中显示一个MessageBox。我通常会:如何使用C#离子WP7中的静态方法显示MessageBox?
this.Dispatcher.BeginInvoke(() => MessageBox.Show("The message"));
但这并不完全适用于静态方法。
如何从静态方法显示MessageBox?
可以使用Application.Current.RootVisual.Dispatcher
访问UI调度员:
Dispatcher dispatcher = Application.Current.RootVisual.Dispatcher;
dispatcher.BeginInvoke(() => MessageBox.Show("The message"));