by Paul Stovell via Paul Stovell on 11/11/2009 6:38:49 AM
Back to: Magellan Home
Magellan's MVC framework is designed to handle navigation between views. However, the views themselves, and how they are implemented, is outside of Magellan's concern. Views can be simple XAML pages, or they can be driven by an MVVM or MVP pattern, or any other way you might like.
Microsoft provide a Visual Studio project template known as the MVVM Toolkit, which makes it easy to get started using the MVVM pattern.
To use Magellan with the MVVM toolkit, you can set up a new MVVM project using the MVVM project template. Then configure it the same way as described in the Magellan quickstart.
By default with the MVVM toolkit, you typically create the ViewModel and View and assign them yourself, as shown in the project template:
Views.MainView view = new Views.MainView(); view.DataContext = new ViewModels.MainViewModel(); view.Show();
Instead, with Magellan, you can assign the controller's Model property to you ViewModel:
public class HomeController : Controller { public ActionResult Main() { Model = new MainViewModel(); return Page(); } }
The view engines will create the page or Window, and set the DataContext to the Model for you. It will then navigate to the page or show the Window.
DataContext
Your ViewModels can make use of commands, event managers, data binding, and all the other common MVVM patterns. MVVM would typically handle:
While Magellan would be used for:
A good way to think about this is to think in terms of the web. On the web, JavaScript is typically the "view model" - it handles the logic for a particular page. The server processes requests for many pages and navigation between pages - that's the job of Magellan.
There is also a NavigateCommand that can be used in ViewModels, instead of the need to use a DelegateCommand/RelayCommand for common navigation events.
DelegateCommand
RelayCommand
Original Post: Magellan and the Microsoft MVVM Toolkit
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.