使用Caliburn MVVM干净地分离UI [英] Clean separation of UI with Caliburn MVVM
问题描述
研究SL的各种MVVM框架。在Caliburn文档中,我在调用MessageBox的控制器中看到了一个代码。这是对的还是仅用于介绍?在Caliburn中是否有像Chinch MVVM中的MessageBox服务之类的东西?
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?
推荐答案
这确实是介绍性代码,只是为了演示控制器方法实际执行。但是,我同意您所指出的问题:演示者中存在原始UI代码可能会导致不适当的混合视图关注。
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.
关于MessageBox服务:在Caliburn v2(树干)ShellFramework模块中,有一个Question / Answer ViewModel,它抽象了MessageBox的功能,其优点是可以为对话框设计UI。
另外,滚动您自己的IMessageBox抽象并使用默认的WPF MessageBox提供基本的实现也非常简单。
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.
这篇关于使用Caliburn MVVM干净地分离UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!