2017-04-27 65 views
-1

我只是不明白为什么我的代码不起作用。而我只想改变一个Button的边框,我看到有人使用TargetType="{x:Type Button}",这不符合我的要求! Set CornerRadius on button template的答案解释了如何更改CornerRadius,我知道如何更改CornerRadius,但我真的不知道为什么我的代码不适用于只有一个按钮。如何更改按钮边框CornerRadius?

<Button Content="OK" BorderThickness="1"> 
    <Button.Resources> 
     <Style TargetType="{x:Type Border}"> 
      <Setter Property="CornerRadius" Value="10"/> 
     </Style> 
    </Button.Resources> 
</Button> 
+3

[设置CornerRadius按钮模板(HTTP://计算器。 com/questions/17681022/set-cornerradius-on-button-template) –

+0

我在代码中看到很多输入错误。这是原因吗?我纠正了所有这些,并且代码在我的最后工作正常。 –

+0

只有'Border'存在于'Button.Content'中,而不是其''Template'中,您的当前代码才会有效。 – AnjumSKhan

回答

0

看来你是一个新手,我建议你拆下按钮Blend中学习如何更改边框可能重复的

+0

Thx为您的答案 – Grey