Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
swdev:dotnet:wpf:implementing_mvvm [2010/12/27 11:20] smayr |
swdev:dotnet:wpf:implementing_mvvm [2013/03/12 17:57] (current) smayr [Resources] |
||
---|---|---|---|
Line 5: | Line 5: | ||
* ViewModel: Models of the data as " | * ViewModel: Models of the data as " | ||
* View: Data binding to ViewModel, with little " | * View: Data binding to ViewModel, with little " | ||
+ | |||
+ | === Model === | ||
+ | |||
+ | === View Model === | ||
+ | |||
+ | <code csharp> | ||
+ | // | ||
+ | // Class TAppViewModel | ||
+ | // | ||
+ | public class TAppViewModel : INotifyPropertyChanged | ||
+ | { | ||
+ | #region Fields, Events, and Properties | ||
+ | // | ||
+ | // Fields | ||
+ | // | ||
+ | private string m_ApplicationName | ||
+ | private string m_ApplicationVersion | ||
+ | private string m_ApplicationBuildNumber = " | ||
+ | private string m_ApplicationDevStage | ||
+ | private int m_Tag = 0; | ||
+ | |||
+ | // | ||
+ | // Events | ||
+ | // | ||
+ | public event PropertyChangedEventHandler PropertyChanged; | ||
+ | | ||
+ | // | ||
+ | // Properties | ||
+ | // | ||
+ | public string ApplicationName | ||
+ | { | ||
+ | get { return m_ApplicationName; | ||
+ | set { m_ApplicationName = value; } | ||
+ | } | ||
+ | public string ApplicationVersion | ||
+ | { | ||
+ | get { return m_ApplicationVersion; | ||
+ | set { m_ApplicationVersion = value; } | ||
+ | } | ||
+ | public string ApplicationBuildNumber | ||
+ | { | ||
+ | get { return m_ApplicationBuildNumber; | ||
+ | set { m_ApplicationBuildNumber = value; } | ||
+ | } | ||
+ | ... | ||
+ | | ||
+ | public TAppViewModel() | ||
+ | { | ||
+ | } | ||
+ | | ||
+ | public void SomeWorkToDo() | ||
+ | { | ||
+ | // Trigger Change | ||
+ | if (PropertyChanged != null) | ||
+ | { | ||
+ | TAppLog.LogMessage(" | ||
+ | PropertyChanged(this, | ||
+ | PropertyChanged(this, | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | </ | ||
+ | |||
=== Main View === | === Main View === | ||
The '' | The '' | ||
Line 28: | Line 92: | ||
</ | </ | ||
- | === User Controls === | + | === User Controls |
User Controls in '' | User Controls in '' | ||
Line 185: | Line 249: | ||
</ | </ | ||
</ | </ | ||
+ | |||
+ | == Resources == | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ |