你如何处理MVVM中的变更跟踪?

时间:2022-12-06 22:50:04

I have written a small helper for doing client-side change tracking objects/dtos to use in my ViewModels (see http://viss.be/2009/04/02/modelviewcontext-client-side-change-tracking/)

我写了一个小助手,用于在我的ViewModel中使用客户端更改跟踪对象/ dtos(请参阅http://viss.be/2009/04/02/modelviewcontext-client-side-change-tracking/)

I didn't find a lot of resources about the subject. So I wonder; how do you typically handle it?

我没有找到关于这个主题的很多资源。所以我想知道;你通常如何处理它?

Thanks, Marc

2 个解决方案

#1


A ViewModel is all about binding the View (UI) to the Model (data). So it should not be responsible for tracking changes, that is something you should be doing inside of you Model classes as they contain the data.

ViewModel就是将View(UI)绑定到Model(数据)。所以它不应该负责跟踪更改,这是你应该在模型类中进行的,因为它们包含数据。

To notify the UI both Model and ViewModel implement INotyfyPorpertyChanged. The ViewModel catches the Model events and propagates them to the View as needed.

要通知UI,Model和ViewModel都实现了INotyfyPorpertyChanged。 ViewModel捕获Model事件并根据需要将它们传播到View。

See http://msmvps.com/blogs/theproblemsolver/archive/2009/04/07/using-model-view-viewmodel-with-silverlight.aspx for a more complete example.

有关更完整的示例,请参见http://msmvps.com/blogs/theproblemsolver/archive/2009/04/07/using-model-view-viewmodel-with-silverlight.aspx。

#2


I didn't find a lot of resources about the subject.

我没有找到关于这个主题的很多资源。

I too want to see more discussion on this topic

我也想看到关于这个主题的更多讨论

So I wonder; how do you typically handle it?

所以我想知道;你通常如何处理它?

  1. Just use DataSet.
  2. 只需使用DataSet。

  3. Keep looking for solutions.
  4. 继续寻找解决方案。

#1


A ViewModel is all about binding the View (UI) to the Model (data). So it should not be responsible for tracking changes, that is something you should be doing inside of you Model classes as they contain the data.

ViewModel就是将View(UI)绑定到Model(数据)。所以它不应该负责跟踪更改,这是你应该在模型类中进行的,因为它们包含数据。

To notify the UI both Model and ViewModel implement INotyfyPorpertyChanged. The ViewModel catches the Model events and propagates them to the View as needed.

要通知UI,Model和ViewModel都实现了INotyfyPorpertyChanged。 ViewModel捕获Model事件并根据需要将它们传播到View。

See http://msmvps.com/blogs/theproblemsolver/archive/2009/04/07/using-model-view-viewmodel-with-silverlight.aspx for a more complete example.

有关更完整的示例,请参见http://msmvps.com/blogs/theproblemsolver/archive/2009/04/07/using-model-view-viewmodel-with-silverlight.aspx。

#2


I didn't find a lot of resources about the subject.

我没有找到关于这个主题的很多资源。

I too want to see more discussion on this topic

我也想看到关于这个主题的更多讨论

So I wonder; how do you typically handle it?

所以我想知道;你通常如何处理它?

  1. Just use DataSet.
  2. 只需使用DataSet。

  3. Keep looking for solutions.
  4. 继续寻找解决方案。