Click here to Skip to main content
15,887,853 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Reading materials for WPF Pin
_Maxxx_31-May-11 13:11
professional_Maxxx_31-May-11 13:11 
GeneralRe: Reading materials for WPF Pin
CodingLover30-May-11 18:29
CodingLover30-May-11 18:29 
AnswerRe: Reading materials for WPF Pin
Abhinav S30-May-11 7:22
Abhinav S30-May-11 7:22 
GeneralRe: Reading materials for WPF Pin
CodingLover30-May-11 18:30
CodingLover30-May-11 18:30 
GeneralRe: Reading materials for WPF Pin
Abhinav S30-May-11 20:06
Abhinav S30-May-11 20:06 
QuestionRe: Reading materials for WPF Pin
CodingLover30-May-11 18:32
CodingLover30-May-11 18:32 
QuestionApplying MVVM (WPF) Pin
jgalak29-May-11 10:49
jgalak29-May-11 10:49 
AnswerRe: Applying MVVM (WPF) [long post] Pin
Keith Barrow29-May-11 12:11
professionalKeith Barrow29-May-11 12:11 
jgalak wrote:
The MVVM model seems applicable, but I'm having a hard time applying it.

Yes, WPF and MVVM go hand and glove.

jgalak wrote:
My initial thought is that I need 4 views (All Clients, All Users, Selected
Client, Selected User), and 2 view models (UserVM and ClientVM). So my first question is: Am I setting this up right? Or should there be 2 more VMs (UserListVM and ClientListVM)? Or vice-versa, 2 views (list and detail) and 4 VMs?

Depends really. My first thought is that you'd need 4 ViewModels and 4 Views, use a "suck it and see" approach.


jgalak wrote:
Following this tutorial: WPF:
MVVM (Model View View-Model) Simplified
I have attempted to do so, but run into a problem right away - that tutorial (and several others) expect the model
class to implement the INotifyPropertyChanged interface. However, since my model class is created by the Entity Designer, it doesn't (as far as I can tell)
implement it.

The article seems closer to Datamodel View ViewModel, which is a good alternative [really as specialised form of] MVVM you can get an idea from Dan Creiver's blog[^]. You can implement the interface on the Enity Data Model: the classes are all partial (Video here[^]) That said there are some objections, some might argue that INotifyPropertyChanged is really a UI construct and is not really "model" stuff. To avoid this you can take a look at a pure MVVM (see Josh Smith's Articl[^]). Note that the disadvantage of this is that changes to the model must come through the viewmodel to be updated on the view, but this is not a problem for you anyway. In either case, the INotitfyPropertyChanged, if implemented correctly in either the model or view model does away with the timer you mentioned.


jgalak wrote:
Next, using the setup from that tutorial, how do I initialize the view? I've built a UserView control (and placed it into my main window) and a UserVM class, all of which bind together with XAML, but when I run it, the control is (understandably) blank. At what point should a User be provided? I'm thinking an overloaded constructor of the UserVM class (using no parameters for a "add user" action, and a single "User" type parameter for an "edit user" function), is there a better way?

Yes: Make the user controls strongly typed data templates and type them to the ViewModels. In the Main window set the DataContext to a new instance of the viewmodel you want to show. The viewmodel should handle the instantiation of the model, you can put the database stuff in the viewmodel, or you could consider a repository pattern (easily googled).


jgalak wrote:
Finally, how do I trigger a write back into the DB once a change has been made
(when the user clicks the save button)?

You raise a command and the ViewModel handles it, again either it commits the changes, or you do it via the repository pattern I mentioned earlier.


jgalak wrote:
I know these are kind of basic

Actually, these are all good questions! Given that you've been out of the loop so long, you've picked up the key techs and points impressively well!

AnswerRe: Applying MVVM (WPF) Pin
_Maxxx_29-May-11 14:27
professional_Maxxx_29-May-11 14:27 
QuestionStorybook.RepeatBehavior not repeating [modified] Pin
Paul R Cotter28-May-11 11:06
Paul R Cotter28-May-11 11:06 
AnswerRe: Storybook.RepeatBehavior not repeating [modified] Pin
Mark Salsbery28-May-11 12:37
Mark Salsbery28-May-11 12:37 
QuestionSilverlight / WPF Every page a content control Pin
DL00127-May-11 5:29
DL00127-May-11 5:29 
AnswerRe: Silverlight / WPF Every page a content control Pin
Mark Salsbery27-May-11 7:33
Mark Salsbery27-May-11 7:33 
AnswerRe: Silverlight / WPF Every page a content control Pin
Abhinav S27-May-11 8:15
Abhinav S27-May-11 8:15 
AnswerRe: Silverlight / WPF Every page a content control Pin
DL00131-May-11 2:58
DL00131-May-11 2:58 
GeneralRe: Silverlight / WPF Every page a content control Pin
Pete O'Hanlon31-May-11 3:26
mvePete O'Hanlon31-May-11 3:26 
QuestionSTYLUS POINT -ELLİPS Pin
mustafayilmaz5627-May-11 3:34
mustafayilmaz5627-May-11 3:34 
QuestionHow to pass a new instance of a viewmodel to an existing usercontrol? Pin
Duke Carey26-May-11 15:08
professionalDuke Carey26-May-11 15:08 
AnswerRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Pete O'Hanlon26-May-11 22:08
mvePete O'Hanlon26-May-11 22:08 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Duke Carey27-May-11 0:42
professionalDuke Carey27-May-11 0:42 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Pete O'Hanlon27-May-11 2:01
mvePete O'Hanlon27-May-11 2:01 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Mycroft Holmes27-May-11 13:54
professionalMycroft Holmes27-May-11 13:54 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Duke Carey31-May-11 0:37
professionalDuke Carey31-May-11 0:37 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Mycroft Holmes31-May-11 13:10
professionalMycroft Holmes31-May-11 13:10 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
_Maxxx_31-May-11 13:32
professional_Maxxx_31-May-11 13:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.