开发者

Exception Handling in MVVMLight

We are using MVVMLight with WPF. Our Views & ViewModels reside in different projects. All the unhandled exceptions occurring in Views can be h开发者_开发技巧andled by app.xaml.cs file but we would also like to catch the unhandled exceptions from ViewModel by providing some centralized exception handling mechanism instead of writing try..catch in every function. Please suggest something as to how we can achieve the above. Thanks


Unhandled exceptions from ViewModels can also be handled in App.xaml.cs. There should not be much difference. App.xaml.cs is a central point of your entire application where you handle all the unhandled exceptions.

Side node: I would not recommend you splitting ViewModels and Views into different assemblies for this and other reasons. See my post here describing why.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜