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>