不将 ViewModel 放在单独的程序集中的充分理由? [英] Good reasons NOT to place ViewModels in separate assembly?

查看:55
本文介绍了不将 ViewModel 放在单独的程序集中的充分理由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 WPF 中的 MVVM 模式开发一个项目.

I'm developing a project using the MVVM pattern in WPF.

MVVM 的主要优势之一是在业务逻辑和表示之间保持清晰的分离.

One of the key benefits to MVVM is maintaining clear separation between business logic and presentation.

为了测试所有内容的实际分离程度,周末我将所有 ViewModel、模型和业务逻辑移动到一个单独的 .dll 中..exe 被保留为一个薄的表示层.

As a test to see how well separated everything actually was, over the weekend I spiked moving all ViewModels, Models, and business logic to a separate .dll. The .exe was left as a thin presentation layer.

这很顺利,第一次尝试.

我已经看到将视图(xaml、演示文稿)保留在 .exe 中并将核心逻辑保留在其自己的 dll 中的好处.例如,不再有 any 困境 在我的脑海中关于 Xaml 中的代码隐藏是否是一个问题:如果它我很满意变得必要,因为我知道它是特定于演示文稿的.

I've already seen benefits to keeping views (xaml, presentation) in the .exe and core logic in its own dll. For example, there's no longer any dilemma in my mind about whether code-behind in Xaml is an issue: I'm comfortable with it if it becomes necessary, since I know it's presentation specific.

到目前为止,这种 exe/dll 分离效果很好,我的问题是:有没有人遇到过这种方法的缺点?

So far this exe/dll separation has worked so well that my question is: Has anyone experienced any downside to this approach?

相关问题:在WPF中实现MVVM而不使用System.Windows.Input.ICommand

推荐答案

现在 2 周,我的 Model &在 dll 中查看模型,在 exe 中查看我的 xaml,没有任何问题.

2 weeks now with my Model & View Models in a dll, my xaml in an exe and no problems whatsoever.

这篇关于不将 ViewModel 放在单独的程序集中的充分理由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆