This project has moved and is read-only. For the latest updates, please go here.

What does MapToViewModelExtension do?

Dec 25, 2011 at 4: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 12:01 PM

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}"/>