2015-12-04 90 views
0

我需要使用WPF繪製一個邊框,其中有一個三角形。如何繪製邊界中間的三角形

這可能嗎?

enter image description here

三角總是關於在邊境中段的底部。邊界寬度大小是動態的

更新:

我試過,但我不知道如何在邊境三角顯示。 這是我的例子:

<Grid Background="Black"> 
     <Border Width="200" Height="80" CornerRadius="20" Background="Red"></Border> 
</Grid> 

而且我的結果:

enter image description here

+1

WPF可以畫出你想要它幾乎任何東西。什麼_you_嘗試過?請提供一個很好的[mcve],清楚地表明你所嘗試的內容,以及對代碼的作用以及如何與你想要的不同的精確解釋。 –

+0

雖然不是您正在尋找的答案,但您可以在Blend SDK中使用「標註」控件。它會節省你很多時間。一個相關的[示例](http://www.c-sharpcorner.com/UploadFile/eda428/use-of-callout-shapes-and-text-property-in-expression-blend/)。如果你沒有安裝Blend,我想你可以添加對'Microsoft.Expression.Drawing' dll的引用,並使用我看到的'Callout'控件 – Insane

回答

3

可以繪製多邊形使用幾乎任何形狀。 這就是我想你想:)

<Grid> 
    <Border CornerRadius="20" Background="Red" Margin="0,0,0,30"></Border> 
    <Polygon Margin="0,0,50,0" 
     HorizontalAlignment="Right" 
     VerticalAlignment="Bottom" 
     Width="50" 
     Height="30" 
     Points="0,0 2,0 1,1" 
     Fill="Red" 
     Stretch="Fill" 
     StrokeThickness="2" /> 
</Grid> 

enter image description here

+0

。我們需要畫兩個不同的部分。非常感謝你。 – qakmak