Multiple Views that have same ViewModel
In my Application business i have 3 step to def开发者_JAVA技巧ine a person...in each step i get some info fro my person... For example i get firstname and lastname in step 1 and persontype in step 2 and get other info in step 3...
I use from transition UI for show steps to my user and using from Fluidkit
for any steps i have a usercontrol ...how can i bind my usercontrols to one ViewModel?
Your question isn't very clear, but yes, you can certainly use the same ViewModel instance for multiple different views.
However, you can also keep your data in a model object, and have your ViewModels just be thin wrappers on top of it. So you could, for example, have a Person object, and have a PersonWizardStepOneViewModel with properties that read values from the Person and write values back to the Person (with any appropriate viewmodel logic added, e.g. enabling/disabling buttons based on other selections that have been made, etc.), a PersonWizardStepTwoViewModel, etc., and pass the Person along instead of sharing the same ViewModel.
It's up to you which way to do it. If the logic doesn't get too complicated and the viewmodel class doesn't get too large, using a single ViewModel instance is probably fine. If the viewmodel starts getting too large to work with comfortably, split it up.
精彩评论