Silverlight Feeds - All your Silverlight feeds in one place.

Sponsors

Tuesday, October 26, 2010

Adding a ViewModelLocator and Merged Dictionaries to App.xaml

by Laurent Bugnion via Silverlight on 10/26/2010 6:49:17 AM

I guess this is one of these places where using Blend is an advantage… since I do these operations mostly with the help of the tool, the XAML is generated and I don’t need to think about it too much.

There is a trick when you add objects (for example Styles or a ViewModelLocator) to App.xaml when it already has merged resource dictionaries. The syntax is a bit convoluted, so here we go:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Skins/Brushes.xaml"/>
        </ResourceDictionary.MergedDictionaries>

        <vm:ViewModelLocator x:Key="Locator"
                                d:IsDataSource="True" />
    </ResourceDictionary>
</Application.Resources>

So yeah, the trick is to put the ViewModelLocator (or any other object for that matter) within the ResourceDictionary tag…

HTH,

Laurent

GalaSoft Laurent Bugnion

email it!bookmark it!digg it!

Original Post: Adding a ViewModelLocator and Merged Dictionaries to App.xaml

Subscribe

New Feed

Product Spotlight

Recently Updated Sources

Legal Note

The content of the postings is owned by the respective author. Silverlight Feeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on Silverlight Feeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.

Advertise with us