我应该如何将WPF MVVM应用于大规模应用程序 [英] How should I approach on applying WPF MVVM to a large scale application
问题描述
我们有一个包含100多个客户的大型winform应用程序。现在我们决定继续推进并使用WPF重新设计应用程序。我已经看了一些关于MVVM模式的例子和以下结构的想法:
服务器端:数据库 - > WCF服务
客户端:DataSource dll(纯数据类)
DataAccess dll(将引用数据源dll并执行数据库相关操作)
BusinessLogic DLL(将引用DataSource和DataAccess dll)
UI_Model dll(将引用DataSource dll和BusinessLogic dll)
UI(将引用UI_Model dll)
请注意我通过为viewModel创建一个单独的dll,从viewmoded(UI_Model)中分离了视图(UI),这是一种正确的方法吗?或者我的视图和viewModel都应该保留在一个项目中?如果有人能告诉我我是在正确的轨道上还是需要改变结构,我将不胜感激。
谢谢
Hi,
We have a large scale winform application with more than 100 clients. Now we have decided to move forward & redesign the app with WPF. I have looked at some examples on MVVM Pattern & thought of below structure:
Server Side: Database -> WCF Service
Client Side: DataSource dll (plain data classes)
DataAccess dll (will refer to data source dll & perform database related operations)
BusinessLogic dll(will refer to DataSource & DataAccess dll)
UI_Model dll (will refer to DataSource dll & BusinessLogic dll)
UI (will refer to UI_Model dll)
Please note I have separated view(UI) from viewmoded (UI_Model) by creating a separate dll for viewModel, is it a correct approach? Or my view & viewModel should both remain in one project? I would appreciate if anyone can suggest me whether I am on a right track or required to change the structure.
Thanks
推荐答案
我不确定你为什么在这里使用UI_Model?会有什么?
我通常在视图模型中使用POCO数据类 - 并将它们包装起来或以其他方式将信息呈现给视图
我还将View和ViewModel分离到解决方案中的不同项目中,View项目引用了ViewModel项目 - 这样我就可以避免意外地从ViewModel引用一些View信息。
所以我通常最终得到:
VIEW绑定到VIEWMODEL,它使用BUSINESSLOGIC提供的DATAOBJECTS通过来自SOMEDATASOURCES的数据库
I'm not sure why you are using a UI_Model here? What would be there?
I normally consume POCO data classes in my view model - and either wrap them or otherwise present the information to the Views
I also separate my View and ViewModel into different projects in the solution, with the View project having a reference to the ViewModel project - that way I avoid accidentally referring to some View information from my ViewModel.
So I normally end up with:
VIEW binds to VIEWMODEL which uses DATAOBJECTS provided by BUSINESSLOGIC via DATASERVICES from SOMEDATASOURCES
这篇关于我应该如何将WPF MVVM应用于大规模应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!