Note that there are some explanatory texts on larger screens.

plurals
  1. POEntity Framework CTP5 Code First, WPF - MVVM modeling
    primarykey
    data
    text
    <p>I have my model all setup for my WPF application and working with entity framework ctp5 code first, here's a sample model class:</p> <pre><code>public class Task { public int ID { get; set; } public int Index { get; set; } public string Content { get; set; } public int Indentation { get; set; } public DateTime Start { get; set; } public decimal Effort { get; set; } public decimal CompletedEffort { get; set; } public decimal Cost { get; set; } } </code></pre> <p>What would be the recommended way to build my view model? My view models will implement INotifyPropertyChanged, I do not want the model classes to have any UI specific code - so that they can be easily reused in other apps. Should I make all of the model properties virtual then override them in the view model? (seems like a lot of unnecessary coding...) Would EF code first play nice with this type of format?</p> <p><strong>Edit</strong> This is a somewhat similar question <a href="https://stackoverflow.com/questions/772214/in-mvvm-should-the-viewmodel-or-model-implement-inotifypropertychanged">In MVVM should the ViewModel or Model implement INotifyPropertyChanged?</a> however, the only solutions appear to be adding in what I consider to be UI logic into the model. Perhaps I can add some sort of delegate to the model and hook into that from the viewmodel, which will in turn use INotifyPropertyChanged... something like this?</p> <pre><code> public class Task { public delegate void HandleChange(string propertyName); public HandleChange ChangeHandler; public int ID { get { return ID; } set { if(ID != value) { ID = value; ChangeHandler("ID"); } } } ... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload