这是我到现在所写的,但这不起作用。第一个线段是OK,从(0,0)到(20,20) - 从左上角到右下角的对角线。但是,第二个线段不是从右上角到左下角绘制的对角线。
我想,我不能正确理解这个元素的语义。
请告诉我如何更正?
<Path Stroke="White" StrokeThickness="3">
<Path.Data>
<GeometryGroup>
<LineGeometry StartPoint="0,0" EndPoint="20,20" />
<LineGeometry StartPoint="20,0" EndPoint="0,20" />
</GeometryGroup>
</Path.Data>
</Path>
这就是它所创造的: -
答案 0 :(得分:2)
将您的路径放在视图框中,使其缩放到按钮的大小。例如
<Grid>
<Button Height="23">
<Viewbox>
<Path Stroke="White" StrokeThickness="3">
<Path.Data>
<GeometryGroup>
<LineGeometry StartPoint="0,0" EndPoint="20,20" />
<LineGeometry StartPoint="20,0" EndPoint="0,20" />
</GeometryGroup>
</Path.Data>
</Path>
</Viewbox>
</Button>
</Grid>
或
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Button HorizontalContentAlignment="Left">
<StackPanel Orientation="Horizontal">
<Viewbox>
<Path StrokeEndLineCap="Triangle" StrokeStartLineCap="Triangle"
Stroke="White" StrokeThickness="3">
<Path.Data>
<GeometryGroup>
<LineGeometry StartPoint="0,0" EndPoint="20,20" />
<LineGeometry StartPoint="20,0" EndPoint="0,20" />
</GeometryGroup>
</Path.Data>
</Path>
</Viewbox>
<TextBlock Margin="5,0,0,0" VerticalAlignment="Center" Text="Press me"/>
</StackPanel>
</Button>
</Grid>