How do I apply a ViewModel to the UserControl inside of a Page?

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-02-28T09:24:44Z Indexed on 2010/04/18 11:03 UTC
Read the original article Hit count: 282

Filed under:
|
|
|

Doing something like this:

<DataTemplate DataType="{x:Type vm:AllCustomersViewModel}">
<vw:AllCustomersView />
</DataTemplate>

works in a ResourceDictionary for when I want to apply a ViewModel to a UserControl as root, but how do I the same thing when I have a UserControl inside of a Page? Would I create a ResourceDictionary for all my Pages then at the top of each Page do something like:

<Page.Resources>
      <ResourceDictionary Source="../MainWindowResources.xaml"/>           
</Page.Resources>

Any help is greatly appreciated, thanks!

© Stack Overflow or respective owner

Related posts about wpf

Related posts about mvvm