.NET Framework 类库
Polyline 类

更新:2007 年 11 月

绘制一系列相互连接的直线。

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

语法

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

此对象与 Polygon 对象类似,不同的是,此对象不需要是闭合的形状。

示例

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

Visual Basic
' Add a Polyline Element
Dim myPolyline As New Polyline()
myPolyline.Stroke = Brushes.SlateGray
myPolyline.StrokeThickness = 2
myPolyline.FillRule = FillRule.EvenOdd
Dim Point4 As New System.Windows.Point(1, 50)
Dim Point5 As New System.Windows.Point(10, 80)
Dim Point6 As New System.Windows.Point(20, 40)
Dim myPointCollection2 As New PointCollection()
myPointCollection2.Add(Point4)
myPointCollection2.Add(Point5)
myPointCollection2.Add(Point6)
myPolyline.Points = myPointCollection2
myGrid.Children.Add(myPolyline)
C#
// Add the Polyline Element
myPolyline = new Polyline();
myPolyline.Stroke = System.Windows.Media.Brushes.SlateGray;
myPolyline.StrokeThickness = 2;
myPolyline.FillRule = FillRule.EvenOdd;
System.Windows.Point Point4 = new System.Windows.Point(1, 50);
System.Windows.Point Point5 = new System.Windows.Point(10, 80);
System.Windows.Point Point6 = new System.Windows.Point(20, 40);
PointCollection myPointCollection2 = new PointCollection();
myPointCollection2.Add(Point4);
myPointCollection2.Add(Point5);
myPointCollection2.Add(Point6);
myPolyline.Points = myPointCollection2;
myGrid.Children.Add(myPolyline);

更多代码

如何:使用 Polyline 元素来绘制折线本示例演示如何通过 Polyline 元素绘制折线(一系列连接的线)。
继承层次结构

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..::.Polyline
线程安全

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

Windows Vista

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

版本信息

.NET Framework

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

参考

其他资源

标记 :


Page view tracker