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

WPF

 
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 
AnswerRe: Applying MVVM (WPF) Pin
_Maxxx_29-May-11 14:27
professional_Maxxx_29-May-11 14:27 
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?


A ViewModel is the model of a View - so you need 4 ViewModels - you CAN have more than one View for a ViewModel if each View is a diffrent visual interpretation of the logic in the ViewModel - but generally I like to think of the viewModel as being the specification of the View's functionality - so, yes, 4 VMs

jgalak wrote:
However, since my model class is created by the Entity Designer, it doesn't (as far as I can tell) implement it. How do I deal with this? I suppose I can just use a timed "refresh" event that manually re-reads from the DB, but that seems inelegant.


properties within the ViewModel should implement INotifyPropertyChanged. some simplified tutorials implement it in the Model but (IMHO) this is entirely the wrong place as far as MVVM goes.

So your Model has a CustomerName property (a plain, old fashioned property). Your ViewModel may also have a CustomerName property, but this one implements INotifyPropertyChanged. The Getter on this VM property can just grab the string straight from the Model's property. And, indeed, the setter can also set the Model's property directly. so the Vm is just presenting the data in a bindable way to the View


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?


I would think that you would first present a list of Users from which the user can select - or click a button to add a new one. so the userListViewmodel would be the thing to first populate


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)?

 


usually your Vm would implement a command, bound tot he button, and would take the data in itself (or in the Model, if you've been updating as the properties in the Vm change) and so your Vm handles the save


If you look at my article (link in the sig) I take you through a WPF MVVM application to maintain customers. It may not be the answer to everything, but it should show you at least one way of looking at it - and a working example is there for D/L to be played with
MVVM# - See how I did MVVM my way
___________________________________________
Man, you're a god. - walterhevedeich 26/05/2011

.\\axxx
(That's an 'M')

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 
GeneralRe: How to pass a new instance of a viewmodel to an existing usercontrol? Pin
Pete O'Hanlon31-May-11 21:37
mvePete O'Hanlon31-May-11 21:37 

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.