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 'St开发者_开发问答yles.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?
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>
精彩评论