简体   繁体   English

具有多个项目的WPF样本数据

[英]WPF Sample Data with Multiple Projects

I have a solution with two projects. 我有两个项目的解决方案。 The first project contains the definition of the database model and the second has the forms. 第一个项目包含数据库模型的定义,第二个项目具有表格。 I wonder what is the best way to use DesignData in the second project with the model defined in the first project. 我想知道在第二个项目中使用在第一个项目中定义的模型的最佳方法是什么。 How do I link? 我该如何连结?

Look into an MVVM architecture 研究MVVM架构

  1. Put the visible window 'forms'/pages into a View project (which only handles user interactions and GUI operations.) 将可见的窗口“窗体” /页面放入View项目(仅处理用户交互和GUI操作)。
  2. Create a View Model project which process the business logic which consumes the database models. 创建一个View Model项目,该项目处理使用数据库模型的业务逻辑。
  3. Use the View Model class(es) to bind to items on the view for display of the data. 使用视图模型类可以绑定到视图上的项目以显示数据。

You get the benefits of MVVM architecture by splitting out and seperating the concerns of the Model, the view and the business logic (view model). 通过拆分并分离模型,视图和业务逻辑(视图模型)的关注点,您将获得MVVM体系结构的好处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM