我们可以使用EllipseGeometry 来绘制一个椭圆或者圆形的图形
EllipseGeometry类: 表示圆或椭圆的几何图形。
下面来看一段代码:
<
Window
x:Class
="WPF.SimpleGraph.Ellipse"
xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml"
Title ="Ellipse" Height ="300" Width ="300" >
< Canvas >
< Path Stroke ="Red" StrokeThickness ="5" >
< Path.Data >
< EllipseGeometry Center ="100,100" RadiusX ="50" RadiusY ="30" ></ EllipseGeometry >
</ Path.Data >
</ Path >
</ Canvas >
</ Window >
xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml"
Title ="Ellipse" Height ="300" Width ="300" >
< Canvas >
< Path Stroke ="Red" StrokeThickness ="5" >
< Path.Data >
< EllipseGeometry Center ="100,100" RadiusX ="50" RadiusY ="30" ></ EllipseGeometry >
</ Path.Data >
</ Path >
</ Canvas >
</ Window >
该代码执行的结果是:
其中EllipseGeometry表示一个椭圆形的几何图形,Center表示该图形的中心圆点在100,100这个坐标上,RadiusX表示横轴半径,RadiusY表示纵轴半径
顾名思义,如果我们想要绘制一个圆形,只需要将横轴半径与纵轴半径值设为一样即可。
<
EllipseGeometry
Center
="100,100"
RadiusX
="50"
RadiusY
="50"
></
EllipseGeometry
>