Monday, April 23, 2012

Frictionless MVVM

I love the concept of sustainable and frictionless development. This morning I started a new WPF project, it aims to be a base for the RavenDB training that we will hold in Perugia in June.
10 steps project bootstrap (5 minutes)
I’m loving it:
  • Create the Visual Studio solution;
  • Add a WPF project;
  • Add some nuget references:
    • Radical;
    • Radical.Windows;
    • Radical.Windows.Presentation;
    • Radical.Extensions.CastleWindsor;
  • Add a reference to the new kid on the block (not yet on nuget): Radical.Windows.Presentation.CastleWindsor;
  • Delete the default MainWindow.xaml;
  • Edit the app.xaml file to remove the StartupUri property;
  • Add a Presentation folder to the project;
  • Create to new items:
    • A WPF window MainView.xaml (*View is important for the default conventions);
    • A class MainViewModel (<ViewName>ViewModel is important for the default conventions);
  • In the app.xaml.cs add a single line of code:
image
  • Press F5 and you are up & running Smile:
image
The application boots, all the default and required services (for MVVM and UI Composition) are wired into Castle Windsor, the MainView is designed as the main window, at boot time the MainView is resolved and using the conventions engine the MainViewModel is wired as the DataContext of the MainView, in the end the MainView is shown.
.m

No comments:

Post a Comment