【发布时间】:2019-05-20 01:14:36
【问题描述】:
我想创建一个边框,它也将覆盖我的<Path> caret 对象。
这是我现在拥有的:
这是我想要的样子:
我尝试使用 Path stroke 和一些 hacky StrokeDashArray 值,但是结果并不令人满意,而且看起来也不对。
在整个网格周围实现包含Path的边框的其他方法是什么?
这是我当前的 XAML 代码:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Path
x:Name="Caret"
Grid.Row="0"
Margin="0,0,15,-1"
HorizontalAlignment="Right"
Panel.ZIndex="1"
Data="M0 10 L 20 10 L 10 0 Z"
Fill="White" />
<Border
Grid.Row="1"
Padding="10"
Background="White"
BorderBrush="Teal"
BorderThickness="1"
CornerRadius="15">
</Border>
</Grid>
【问题讨论】:
-
您可以考虑自定义 Shape,即从 Shape 派生的类,它覆盖 DefiningGeometry 属性和 OnRenderSizeChanged 方法。