开发者

Resource Dictionary Styles not available to UserControl

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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜