App patterns for simple lob crud

Topics: Getting Started
Dec 30, 2011 at 1:52 AM

I'm just starting to learn CM, and stuck on the most basic questions of how to correctly design a CM WPF app with modal forms for adding and editing records.

From the various examples I've read and experimented with it seems like separate view models are needed for an 'add' dialog and for an 'edit' dialog. Does it have to be this way? I guess they can inherit from a common class so there isn't too much duplication of code, but I wondered if the correct pattern would use a single view model for both operations and, if so, how to invoke the appropriate view for the operation.

Is there a best/recommended way to solve this?

- Chris

Coordinator
Dec 30, 2011 at 12:21 PM

With CM, you can have multiple Views over the same ViewModel by using a View Context. You can also use the IWindowManager to show screens modally, based on ViewModel (and context). Have a look at the HelloWindowManager sample for an example of this.

Jan 2, 2012 at 11:24 PM

Thanks. Together with re-reading Multiple Views over the Same ViewModel that pointed me in the right direction.