【发布时间】:2016-07-11 04:02:20
【问题描述】:
我检查了类似的问题,但我无法弄清楚基本逻辑。
我正在尝试将 CornerRadius 添加到 WPF 项目中的 TextBox 中。
到目前为止,这是我尝试过的:
在App.xaml 中,我创建了一个Style,我打算重用它:
<Style x:Key="TextBoxStyle" TargetType="{x:Type TextBox}">
<Setter Property="Height" Value="27"/>
<Setter Property="Padding" Value="5.5"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
添加:<Setter Property="Border.CornerRadius" Value="5"/> 无效。但是,以下方法有效,但有副作用(所有边框都为圆形):
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="5"/>
</Style>
我想保持样式分开,基本上像这样使用它们:
<TextBox x:Name="ExampleTb" Style="{StaticResource TextBoxStyle}"/>
你能帮我/指出正确的方向吗?
【问题讨论】: