by Paul Stovell via Paul Stovell on 11/10/2009 1:07:43 PM
Back to: Magellan Home
Magellan was designed to work with Composite WPF from day one. Composite WPF provides support for multiple modules, loosely coupled pub/sub eventing, and regions for sub-dividing zones in the UI. However, Composite WPF does not enforce any particular UI pattern - MVVM, MVP and MVC could all work.
Magellan and Composite WPF can work well together to create a composite navigation-oriented application using the MVC pattern. Here are some examples:
For region support, Magellan.Composite.dll contains some extensions that can be used. A controller may look like this:
public class ShellController : CompositeController { public ActionResult Explorer() { return CompositeView("Explorer").InRegion("LeftRegion"); } }
On application startup, the view can be navigated to via:
Navigator.Primary.Navigate("Shell", "Explorer");
Lastly, an additional Region View Engine needs to be registered. As discussed in the IOC topic, you can also use a custom view activator to control how views are instantiated, if you want to use IOC. In this case we'll use the Microsoft common ServiceLocator:
ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new PageViewEngine(new ServiceLocatorViewActivator())); ViewEngines.Engines.Add(new WindowViewEngine(new ServiceLocatorViewActivator())); ViewEngines.Engines.Add(new CompositeViewEngine(new ServiceLocatorViewActivator()));
When the InRegion extension method is used, and the view class derives from UIElement, the region view engine will use the service locator to resolve the default RegionManager, and then add the view to the region.
InRegion
UIElement
RegionManager
There is also a new controller factory that can be used with the Common Service Locator. It will automatically back onto ServiceLocator.Current to resolve controllers, so you just have to register them in the container:
ServiceLocator.Current
ControllerBuilder.Current.SetControllerFactory(new ServiceLocatorControllerFactory());
See also:
Original Post: Magellan and Composite WPF
The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.