6

I have the following style:

<Style x:Key="WhiteStyle" TargetType="{x:Type Label}">               
    <Setter Property="BorderBrush" Value="White"/>
    <Setter Property="BorderThickness" Value="2"/>    
</Style>

However, I would like to add the property CornerRadius and modify the value. Unfortunately, the XAML error says a Label does not have a CornerRadius property. My question, How must I modify this XAML?

Thanks,

4

1 回答 1

13

错误是正确的,您不能在标签上设置圆角半径。

您可以做的是用边框包裹标签并将您的样式应用到它以获得所需的外观。

编辑:

风格资源:

<Style x:Key="MyBorderStyle" TargetType="Border">
      <Setter Property="BorderBrush" Value="White" />
      <Setter Property="BorderThickness" Value="2" />
      <Setter Property="CornerRadius" Value="3" />
</Style>

边框包裹标签:

<Border Style="{StaticResource MyBorderStyle}">
    <Label Content="My Label" />
</Border>
于 2013-07-12T18:46:46.910 回答