按钮内的中心路径内容

Bri*_*ell 1 wpf

我有一个从 Inkscape 导出的非常简单的路径(只是一个 + 符号),我想将它用作按钮的内容,但是当我这样做时,路径偏离了中心。

偏心路径

<Button Height="24" Width="24">
    <Viewbox HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Fill">
        <Path Fill="#000000" Data="M 11 5 L 11 11 L 5 11 L 5 13 L 11 13 L 11 19 L 13 19 L 13 13 L 19 13 L 19 11 L 13 11 L 13 5 L 11 5 z"/>
    </Viewbox>
</Button>
Run Code Online (Sandbox Code Playgroud)

我在一个包裹它Viewbox,所以我可以扩展它,我试着播放HorizontalAlignmentVerticalAlignmentLayoutRounding,但他们似乎并没有影响定位。

我猜路径数据本身对此负责..可能从第一个 Move To (M) 开始,但我对手动编辑路径没有信心。

有什么办法可以纠正这个问题,让它在按钮内居中显示?我有更多的按钮要构建,所以我想了解发生了什么。

这是原始的SVG:

<svg xmlns="http://www.w3.org/2000/svg" version="1" viewBox="0 0 24 24" enable-background="new 0 0 24 24" width="48" height="48">
<path style="text-indent:0;text-align:start;line-height:normal;text-transform:none;block-progression:tb;-inkscape-font-specification:Bitstream Vera Sans" d="M 11 5 L 11 11 L 5 11 L 5 13 L 11 13 L 11 19 L 13 19 L 13 13 L 19 13 L 19 11 L 13 11 L 13 5 L 11 5 z" color="#000" overflow="visible" enable-background="accumulate" font-family="Bitstream Vera Sans"/>
Run Code Online (Sandbox Code Playgroud)

谢谢你!!

Joh*_*son 6

使用这样的东西:

<Button Width="24" Height="24">
    <Path Margin="2"
          Data="M 11 5 L 11 11 L 5 11 L 5 13 L 11 13 L 11 19 L 13 19 L 13 13 L 19 13 L 19 11 L 13 11 L 13 5 L 11 5 z"
          Fill="#000000"
          Stretch="Fill" />
</Button>
Run Code Online (Sandbox Code Playgroud)

ViewBox当你有一个时不需要Path