Aks
Aks

Reputation: 5236

Silverlight page goes blank when style is in another file

I've styled a Silverlight DataGrid control and when the style is in UserControl.Resources, it applied to the DataGrid correctly. But If I move it to a Styles.xaml file and add the following to App.xaml,

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Themes/GridStyle.xaml" />
            <ResourceDictionary Source="Themes/Styles.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

The page just goes blank after loading and I get the "Error" Icon in the browser status bar.

This is not something to do with the style file not being loaded because several other styles from the 'Styles.xaml' file apply correctly. Only one style causes this error.

Note: The Style has an element with a binding to the viewmodel which is defined in UserControl.DataContext. Could this have something to do with it?

Upvotes: 0

Views: 132

Answers (1)

Vladimir Dorokhov
Vladimir Dorokhov

Reputation: 3839

Try

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/[Project name];component/Themes/GridStyle.xaml"/>
            <ResourceDictionary Source="/[Project name];component/Themes/Styles.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

Upvotes: 1

Related Questions