【发布时间】:2019-11-07 01:22:26
【问题描述】:
我正在尝试通过 XAML 代码实现this,但无济于事。
我有以下 XAML 代码:
App.xaml
<Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Background" Value="Black"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Path Fill="{TemplateBinding Background}"
Data="M 0,22.5 22.5,0 27.5,5 10,22.5 27.5,40 22.5,45"/>
<Border x:Name="border"
BorderThickness="2"
BorderBrush="Red"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
然后像这样使用它:
<Button Style="{StaticResource ButtonStyle}" Height="100" Width="100"/>
它给了我this,但我希望红色边框位于按钮内。
我尝试添加这个
<Setter Property="BorderBrush" Value="Red"/>
<Setter Property="BorderThickness" Value="2"/>
而不是创建一个网格,但现在不显示边框。
我想我可以创建另一条路径作为边框,但有没有更简单的方法?
【问题讨论】: