How do I maintain coherency between model and view-model in MVVM pattern?
Posted
by Mike Garrett
on Stack Overflow
See other posts from Stack Overflow
or by Mike Garrett
Published on 2009-02-03T13:24:03Z
Indexed on
2010/06/14
8:02 UTC
Read the original article
Hit count: 314
Problem Statement
I'm writing a very basic WPF application to alter the contents of a configuration file. The data format is an XML file with a schema. I want to use it as a learning project for MVVM, so I have duly divided the code into
Model: C# classes auto-generated from xsd.exe
View-Model: View-friendly representation of the Model.
View: Xaml and empty code behind
I understand how the View-Model can make View-binding a breeze. However, doesn't that leave the View-Model <-> Model semantics very awkward? Xsd.exe generates C# classes with arrays for multiple XML elements. However, at the V-VM level you need Observable Collections.
Questions:
Does this really mean I have to keep two completely different collection types representing the same data in coherence?
What are the best practices for maintaining coherence between the Model and the View-Model?
© Stack Overflow or respective owner