Model View Design Question

Topics: UI Architecture
Jan 19, 2012 at 2:46 PM
Edited Jan 19, 2012 at 2:55 PM


I have currently started on using CM in WPF application. I have a scenario where I have a view with a Bing Map on it. This view can be launched from different places. So currently I always publish an event from where I need to launch this view and the ShellViewModel which subscribes to these events launches this map view. The map view also has a set of user controls which let user edit and sketch a shape on map. These set of controls differ based on where the map view is being launched from. So currently I am passing a variable to mapviewmodel which determines which tools to show. However now these set of tools are growing and I dont think this is the right way to handle it. 

Ideally I would like each set of tools to be its own view which can be activated on a MappingView based on where mapping view is being launched. Or should I create a separate mapping view for each scenario. But in that case where do I place common functionality that is embedded in mapviewmodel.


I read something about conductor and conductwith but am not sure whats the best way to handle this scenario.

If someone can point me to right direction, it would be very helpful.





Jan 19, 2012 at 5:26 PM

It's hard to answer decisively without knowing more details. But here's an idea: Think about modeling your map tools. Perhaps create an IMapTool interface. These can actually be ViewModels in their implementation, each with their own views. The MapViewModel can use IoC to compose all available IMapTool implementations. Using some metadata, the MapViewModel can select from the available list of IMapTools which ones are appropriate for the given scenario which it can add to a list. The list can be bound in the UI which will compose all the tool's views. So, you will have one map view, but various portions of it will be dynamically composed based on what tools are selected.

Jan 19, 2012 at 6:23 PM
Edited Jan 19, 2012 at 6:46 PM

Thank you so much for a good direction! 


So each tool wl implement and IMapTool interface? Does this look right?

public interface IMapTool    {        BaseViewModel ViewModel;    }

And when you mention binding UI with a list of you mean I should have a content control and bind it to the list of tools. Similar to what I do in ShellView to activate diff views? Or should MapViewModel can activate different view models?

Please pardon my ignorance.



Jan 19, 2012 at 8:07 PM

I imagine your MapView would have an ItemsControl bound to the current list of IMapTools such that Caliburn.Micro can compose all of them into the view.