2016-11-10 61 views
0

我有一個非常簡單的路徑(只是一個+符號),我從Inkscape中導出,我想用它作爲按鈕的內容,但是當我這樣做時,路徑偏離中心。按鈕內的中心路徑內容

Offcenter Path

<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> 

我包裹在一個Viewbox,所以我可以擴展它,我已經試過了HorizontalAlignmentVerticalAlignmentLayoutRounding打不過他們似乎並沒有影響到定位。

我猜路徑數據本身是負責這個..可能從第一個移動到(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"/> 

謝謝!!

回答

3

使用這樣的事情:

<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> 

無需一個ViewBox當你有一個Path

+0

謝謝!我沒有想到把實際路徑中的邊距和拉伸放在一邊。我一直在推翻XAML。 – MagellanTX