开发者

Silverlight apply implicit style that sets other style

开发者 https://www.devze.com 2023-03-20 04:20 出处:网络
I have a TextBox Style with a Key defined in external resource dictionary file, then I\'m trying to define a new implicit TextBox Style that sets \"Keyed\" style from resource dictionary, so basically

I have a TextBox Style with a Key defined in external resource dictionary file, then I'm trying to define a new implicit TextBox Style that sets "Keyed" style from resource dictionary, so basically I want to seet the style from resource dictionary as a default for TextBox, but I c开发者_StackOverflowan't remove Key from there, because it is used by other code.

<ResourceDictionary Source="FileWithNiceTextBoxStyle.xaml"/>
<Style TargetType="TextBox">
    <Setter Property="Style" Value="{StaticResource NiceTextBoxStyle}"/>
</Style>

However this doesn't work, and result in Visual Studio crash.


Use the BasedOn attribute:

<Style TargetType="TextBox" x:Key="GlobalTextBox">
    <Setter Property="Background" Value="Pink"/>
</Style>
<Style TargetType="TextBox" BasedOn="{StaticResource GlobalTextBox}"></Style>
...
<TextBox Text="I have pink background"/>
0

精彩评论

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