I have a page (view) in my Windows Phone 7 application that uses the Silverlight Map control.
I need to call the SetView method on the control, but I’d like to stick to the MVVM style of keeping functionality in the view model.
I plan to call this method after clicking on an application bar button, so I don’t have access to the Map via the EventArgs parameter.
What’s the best way to do this?
I haven’t worked with the map control myself, but here’s a couple of ideas off of the top of my head:
You could publish an event using the IEventAggregator which the view could be subscribed to and use to call SetView.
You could implement a custom IResult which uses the ActionExecutionContext to get the view, find the map control and call SetView on it.
You could implement IViewAware on your view model (or override OnViewLoaded if you inherit from Screen) and follow a more Supervising Controller approach by interacting with the view through an interface to call SetView.