Clean separation of UI with Caliburn MVVM

时间秒杀一切 提交于 2019-12-11 16:41:13

问题


Looking into various MVVM frameworks for SL. In the Caliburn documentation I saw a code in a controller that calls MessageBox. Is this right or is this just for intro? Is there something like MessageBox service in Caliburn like in Chinch MVVM?


回答1:


It's indeed introductive code, just to demonstrate that the controller method is actually executed. Yet, I agree on the issue you pointed out: the presence of raw UI code in the presenter could lead to an inappropriate mix of view concerns.

About the MessageBox service: in Caliburn v2 (trunk), ShellFramework module, there is a Question/Answer ViewModel abstracting the functionality of a MessageBox, with the advantage of letting you to design the UI for the dialog. Also, it's very straightforward to roll your own IMessageBox abstraction and provide a basic implementation using the default WPF MessageBox.




回答2:


Marco is correct. This is just to demonstrate that the action is called. I wouldn't recommend this in practice. I will try to make some changes to the samples or add some comments that make this clearer. Caliburn has services built-in for calling custom message boxes.



来源:https://stackoverflow.com/questions/2682101/clean-separation-of-ui-with-caliburn-mvvm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!