开发者

Silverlight apply implicit style that sets other style

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜