So I have made a resource dictionary of styles to use and included it in my UserControl:
<UserControl.Resources>
<ResourceDictionary Source="../affinitySty开发者_如何学Goles.xaml" />
</UserControl.Resources>
Which makes it available to all the controls in the UserControl, but not the UserControl itself. I am guessing this is because that bit of code comes after the UserControl tag.
How can I use Resource Dictionary defined styles for my UserControl background?
One option is to use DynamicResource rather than StaticResource; this postpones resolution until runtime.
Alternately, you can use the following XAML property syntax and place it after the ResourceDictionary is merged in:
<UserControl.Background>
<StaticResource ResourceKey="SomeResourceKey"/>
</UserControl.Background>
精彩评论