wpf中的多种样式

wpf中的多种样式,wpf,xaml,Wpf,Xaml,我想从静态资源定义我的文本框的设计,如何应用它 目前我有: <TextBox Style="{StaticResource TextBoxHeight }" /> 但我需要: <TextBox Style="{StaticResource TextBoxHeight }" Style="{StaticResource TextBoxBorder }" /> 但是它会给出错误“属性'Style'设置了多次”您不能多次设置属性。您不能将带有边框的TargetTy

我想从静态资源定义我的
文本框的设计,如何应用它

目前我有:

<TextBox  Style="{StaticResource TextBoxHeight }" />
但我需要:

<TextBox   Style="{StaticResource TextBoxHeight }" Style="{StaticResource TextBoxBorder }" />


但是它会给出错误“属性'Style'设置了多次”

您不能多次设置
属性。您不能将带有
边框的
TargetType
样式应用于
文本框。但是在
按钮
样式的
参考资料
字典中放置隐式
边框
样式应该可以:

<Style x:Key="TextBoxHeight1" TargetType="{x:Type TextBox}" >
    <Setter Property="Height" Value="20"/>
    <Style.Resources>
        <Style TargetType="{x:Type Border}">
            <Setter Property="CornerRadius" Value="10"/>
        </Style>
    </Style.Resources>
</Style>

<Style x:Key="TextBoxHeight1" TargetType="{x:Type TextBox}" >
    <Setter Property="Height" Value="20"/>
    <Style.Resources>
        <Style TargetType="{x:Type Border}">
            <Setter Property="CornerRadius" Value="10"/>
        </Style>
    </Style.Resources>
</Style>