.NET Framework 类库
Ellipse 类

更新:2007 年 11 月

绘制一个椭圆。

命名空间:  System.Windows.Shapes
程序集:  PresentationFramework(在 PresentationFramework.dll 中)
用于 XAML 的 XMLNS:http://schemas.microsoft.com/winfx/xaml/presentation

语法

Visual Basic(声明)
Public NotInheritable Class Ellipse _
    Inherits Shape
Visual Basic (用法)
Dim instance As Ellipse
C#
public sealed class Ellipse : Shape
Visual C++
public ref class Ellipse sealed : public Shape
J#
public final class Ellipse extends Shape
JScript
public final class Ellipse extends Shape
XAML 对象元素用法
<Ellipse .../>
备注

椭圆的默认 Stretch 值为 Fill

示例

下面的示例演示如何使用代码创建 Ellipse 并设置其属性。有关完整的示例,请参见 WPF 形状库示例

Visual Basic
' Add an Ellipse
Dim myEllipse As New Ellipse()
myEllipse.Stroke = Brushes.Black
myEllipse.Fill = Brushes.DarkBlue
myEllipse.HorizontalAlignment = HorizontalAlignment.Left
myEllipse.VerticalAlignment = VerticalAlignment.Center
myEllipse.Width = 50
myEllipse.Height = 75
myGrid.Children.Add(myEllipse)
C#
// Add an Ellipse Element
myEllipse = new Ellipse();
myEllipse.Stroke = System.Windows.Media.Brushes.Black;
myEllipse.Fill = System.Windows.Media.Brushes.DarkBlue;
myEllipse.HorizontalAlignment = HorizontalAlignment.Left;
myEllipse.VerticalAlignment = VerticalAlignment.Center;
myEllipse.Width = 50;
myEllipse.Height = 75;
myGrid.Children.Add(myEllipse);

更多代码

如何:绘制椭圆或圆此示例演示如何通过使用 Ellipse 元素绘制椭圆或圆。若要绘制椭圆,请创建一个 Ellipse 元素并指定其 WidthHeight。使用其 Fill 属性来指定用于绘制椭圆内部区域的 Brush。使用其 Stroke 属性来指定用于绘制椭圆轮廓的 BrushStrokeThickness 属性指定椭圆轮廓的粗细。
如何:使用纯色绘制区域若要使用纯色绘制区域,可以使用预定义的系统画笔,如 RedBlue,也可以创建一个新的 SolidColorBrush,并使用 Alpha、红、绿、蓝值描述其 Color。在 XAML 中,您还可以使用十六进制表示法来利用纯色绘制区域。
继承层次结构

System..::.Object
  System.Windows.Threading..::.DispatcherObject
    System.Windows..::.DependencyObject
      System.Windows.Media..::.Visual
        System.Windows..::.UIElement
          System.Windows..::.FrameworkElement
            System.Windows.Shapes..::.Shape
              System.Windows.Shapes..::.Ellipse
线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。
平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.5、3.0
另请参见

参考

其他资源

标记 :


Page view tracker