WPF使用绘制圆形

绘制圆形

以下代码绘制的是一个黑色边框的圆 可以通过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>

 

posted @ 2021-12-01 15:07  飞天猪皮怪  阅读(2154)  评论(0编辑  收藏  举报