Regarding the ViewModel

Posted by mizipzor on Stack Overflow See other posts from Stack Overflow or by mizipzor
Published on 2010-06-02T07:53:40Z Indexed on 2010/06/02 7:53 UTC
Read the original article Hit count: 220

Filed under:
|
|
|

Im struggling to understand the ViewModel part of the MVVM pattern. My current approach is to have a class, with no logic whatsoever (important), except that it implements INotifyPropertyChanged. The class is just a collection of properties, a struct if you like, describing an as small part of the data as possible. I consider this my Model.

Most of the WPF code I write are settings dialogs that configure said Model. The code-behind of the dialog exposes a property which returns an instance of the Model. In the XAML code I bind to subproperties of that property, thereby binding directly to the Model's properties. Which works quite well since it implements the INotifyPropertyChanged. I consider this settings dialog the View.

However, I havent really been able to figure out what in all this is the ViewModel. The articles Ive read suggests that the ViewModel should tie the View and the Model together, providing the logic the Model lacks but is still to complex to go directly into the View. Is this correct? Would, in my example, the code-behind of the settings dialog be considered the ViewModel?

I just feel a bit lost and would like my peers to debunk some of my assumptions. Am I completely off track here?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about design-patterns