2015-04-30 64 views
1
按鈕圖像

我已經使用多邊形一個小十字圖標如下:加載自定義多邊形在WPF

<Viewbox Margin="28,-22,-28,22"> 
     <Polygon 
Points="300, 200 325,200 325,250 375,250 375,275 325,275 325,325 300,325 300,275 250,275 250,250 300,250 300,200" Height="513" Width="595"> 
      <Polygon.Fill> 
       <SolidColorBrush Color="#666666" Opacity="100"/> 
      </Polygon.Fill> 
      <Polygon.RenderTransform> 
       <RotateTransform CenterX="313" CenterY="237" Angle="45" /> 
      </Polygon.RenderTransform> 
     </Polygon> 
    </Viewbox> 

現在我想這個多邊形被加載到我的按鈕。我怎樣才能做到這一點?

回答

3

把那裏面Button.Content

<Button ...> 
    <Viewbox ...> 
    </Viewbox> 
</Button> 

不要忘記刪除ViewBox.Margin(使Button足夠大)或使其負。


enter image description here

+0

謝謝。現在的問題是如何讓ViewBox將多邊形包裹起來而不會在其周圍留下任何額外空間? – eYe

+0

有許多選項:1)改變點,使他們從'(0,0)'開始2)縮放3)負邊界4)渲染變換等。參見編輯。 – Sinatr