This project has moved. For the latest updates, please go here.

What does MapToViewModelExtension do?

Dec 25, 2011 at 3:32 PM


I don't understand the role of the custom markup extension: MapToViewModelExtension.

Is it an alternative to the following code to map a view to a view model?

        /// <summary>
        ///     This will allow the binding of the view model to the view
        /// </summary>
        public ViewModelRoute Binding
                return ViewModelRoute.Create(

The second snippet work well, while the first one doesn't display anything.

Am i misunderstanding something?




Dec 27, 2011 at 11:01 AM

Yes. This is a way to connect to a view model in Xaml markup, so you can do something like:

<Grid DataContext="{MapToViewModel ViewModel=MyViewModel}"/>