此示例演示如何使用 Ellipse 元素绘制省略号和圆圈。 若要绘制椭圆,请创建一个 Ellipse 元素并指定其 Width 和 Height。 使用其 Fill 属性指定用于绘制椭圆形内部的 Brush。 使用其 Stroke 属性指定用于绘制椭圆形轮廓的 Brush。 StrokeThickness 属性指定椭圆轮廓的粗细。
若要绘制圆圈,请使 Width 元素 Height 和 Ellipse 彼此相等。
示例:
<Canvas Height="200" Width="200">
<!-- Draws an oval with a blue interior. -->
<Ellipse
Width="100"
Height="50"
Fill="Blue"
Canvas.Left="10"
Canvas.Top="25" />
<!-- Draws an oval with a blue interior and a black outline. -->
<Ellipse
Width="100"
Height="50"
Fill="Blue"
Stroke="Black"
StrokeThickness="4"
Canvas.Left="10"
Canvas.Top="100"/>
<!-- Draws a circle with a blue interior. -->
<Ellipse
Width="50"
Height="50"
Fill="Blue"
Canvas.Left="135"
Canvas.Top="25"/>
<!-- Draws a circle with a blue interior and a black outline. -->
<Ellipse
Width="50"
Height="50"
Stroke="Black"
StrokeThickness="4"
Canvas.Left="135"
Canvas.Top="100" />
</Canvas>
虽然此示例使用 Canvas 来包含椭圆,但可以将省略号元素(以及所有其他形状元素)与支持非文本内容的任何 Panel 或 Control 一起使用。
此示例是较大示例的一部分;有关完整示例,请参阅 形状元素示例。