Catel:在AsynchronousCommand中使用IMessageService

时间:2013-07-30 15:14:00

标签: c# wpf mvvm catel

我将AsynchronousCommand绑定到View的Button。 我需要做的是在用户点击按钮时验证窗口的一些文本框。 如果验证失败,则应向用户显示错误消息框。

我如何使用IMessageService执行此操作?

使用此代码:

            var messageService = GetService<IMessageService>();
            messageService.ShowError("Bitte wählen Sie einen Plan aus!");

我收到IvalidOperationException:invalidoperationexception调用线程无法访问此对象,因为另一个线程拥有它。

我该如何避免这个问题?

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

您需要使用IDispatcherService进行调度。总是在MessageService中调度可能会很有趣。

如果您对此功能感兴趣,请添加功能请求here