繪制圓形
以下代碼繪制的是一個黑色邊框的圓 可以通過StrokeThickness設置邊框的寬度。
<Grid> <!--圓型--> <Path Stroke="Black" Fill="White" StrokeThickness="4" HorizontalAlignment="Center" VerticalAlignment="Center" > <Path.Data > <EllipseGeometry Center="100,100" RadiusX="100" RadiusY="100" > </EllipseGeometry> </Path.Data> </Path> </Grid>
擴展同心圓
Ellipse 是用於繪制橢圓的,如果它的寬度和高度都相等那么就變成了圓,這里需要注意如果不給Zindex這個圓是在底層的是看不到的。
<Grid> <!--圓型--> <Ellipse Stroke="Red" StrokeThickness="1" Width="90" Height="90" Panel.ZIndex="1"/> <Path Stroke="Black" Fill="White" StrokeThickness="4" HorizontalAlignment="Center" VerticalAlignment="Center" > <Path.Data > <EllipseGeometry Center="100,100" RadiusX="100" RadiusY="100" > </EllipseGeometry> </Path.Data> </Path> </Grid>