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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM