How can I map multiple ViewModels with a certain name pattern to a single view?

Topics: Conventions, Getting Started
Jan 17, 2013 at 6:18 PM

I've been working with CM (and Gemini) for a few days and I am very impressed by the features that it offers. Great stuff !

I have a a bunch of ViewModels (compiled at runtime with CodeDom) that should all share a single View. Each of these ViewModels is named with the pattern


and the view they should be using is CustomView.xaml.

I tried adding a NameTranslator like this:

ViewLocator.NameTransformer.AddRule(".*CustomViewModel", "CustomView");

...but it didn't work out. I also tried to do some funny stuff with the ViewLocator, but it seems that I'm hitting my head to the wall.

Is there any straightforward way to implement this kind of "fixed" mapping of a view to multiple viewmodels ?