Click here to Skip to main content
16,008,175 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I downloaded an example from below URL

I am confused about how views are getting loded when the ContentControl is bound to ViewModel in ApplicationView.xaml in this example. Nowhere in the code Views as associated with ViewModel.

Can someone please explain me about this?

http://rachel53461.wordpress.com/2011/12/18/navigation-with-mvvm-2/[^]
Posted
Comments
[no name] 21-Mar-13 18:06pm    
Perhaps you missed this in the "Views" section, "This allows me to use DataTemplates to tell WPF how to draw each IPageViewModel".
Member 3660629 22-Mar-13 9:25am    
Thanks Phantom, you are right. I really missed DataTemplates. Thanks for the answer.
Sergey Alexandrovich Kryukov 21-Mar-13 18:47pm    
Why not asking Rachel about it? I would not take any responsibility for explaining her view on this.
—SA
Member 3660629 22-Mar-13 9:27am    
Hi Sergey, i appreciate your suggestion. As this is learning phase for me i thought of asking the question in forums. Going ahead i will follow your suggestion. Thanks.
Sergey Alexandrovich Kryukov 22-Mar-13 11:33am    
Great.
—SA

1 solution

If you define a DataTemplate in your Resources that has a DataType property but not a Key property, it is considered an Implicit DataTemplate. This means, it will be used anytime WPF tries to render an object of the specified DataType.

My example has DataTemplates without a Key property defined for each of the ViewModels, so when WPF tries to render the ViewModel into the ContentControl.Content area, it uses the specified DataTemplate instead =)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900