【问题标题】:WPF label stylingWPF 标签样式
【发布时间】:2013-07-12 18:41:05
【问题描述】:

我有以下风格:

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

但是,我想添加属性CornerRadius 并修改值。不幸的是,XAML 错误表明 Label 没有 CornerRadius 属性。我的问题,我必须如何修改这个 XAML?

谢谢,

【问题讨论】:

标签: wpf xaml label cornerradius


【解决方案1】:

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

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

编辑:

样式资源:

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

【讨论】:

    猜你喜欢
    • 2012-09-25
    • 2010-12-01
    • 2011-01-13
    • 2016-01-03
    • 2010-12-03
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 2020-07-27
    相关资源
    最近更新 更多