2011-07-13 34 views
1

我有一个文本框样式与在外部资源字典文件中定义的一个键,然后我试图定义一个新的隐式文本框样式从资源字典中设置“键控”样式,所以基本上我想从资源字典中选择作为TextBox默认值的样式,但我无法从中删除Key,因为它被其他代码使用。Silverlight应用隐式样式,设置其他样式

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

但是,这不起作用,并导致Visual Studio崩溃。

回答

2

使用BasedOn属性:

<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"/>