I have recently started investigating the MVVM pattern with WPF for an upcoming project. I started with Josh Smith\'s MSDN article. I have a question (well many, but let\'s
There's no reason why you shouldn't be able to achieve that. One way of doing this is to provide some flag in your view model stating whether you're in add mode or in edit mode, and styling your view based on that flag using simple bindings, triggers or template selectors.
For reference you may look at Sacha Barber's DataWrapper class that's part of his Cinch
framework (not directly applicable to your case, but it's a good starting point) which wraps data fields in the view model in such a way to support a flag to toggle between read only (view record mode), and read-write (edit record mode). You could apply a similar approach to make the distinction between add and edit.
Basically, instead of having simple properties in your view model, instantiate a data wrapper class which includes a Value
property, and a IsAdding
property. In your view, you can use bindings, triggers or template selectors to modify templates based on that property.