通过Xaml改变边框厚度,`wpf`

时间:2015-10-18 01:17:06

标签: wpf xaml wpf-controls

请注意我是WPF的新用户,我试图通过Buttonborder thickness .Xaml templates提供.Xaml值,但是,它不起作用,这是我的 <Button> <Button.Style> <Style TargetType="{x:Type Button}"> <Setter Property="Background" Value="#FFFFFFFF" /> <Setter Property="Foreground" Value="#FFF01F1F" /> <Setter Property="BorderBrush" Value="#FFF01F1F" /> <Setter Property="BorderThickness" Value="5" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border Background="{TemplateBinding Background}"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> </ControlTemplate> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="IsMouseOver" Value="true"> <Setter Property="Background" Value="#FFF01F1F" /> <Setter Property="Foreground" Value="#FFFFFFFF" /> </Trigger> </Style.Triggers> </Style> </Button.Style> </Button>

IsMouseOver

先谢谢。

更新:::

我已尝试Change Thickness回答,但现在它会禁用我的{{1}}属性,

1 个答案:

答案 0 :(得分:1)

您设置了自己的自定义模板,该模板不使用按钮本身的BorderThickness属性,因此应该是:

  <Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}">
         <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
   </Border>

或者您可以直接在模板上将其设置为5.