Compartir a través de


Cómo: Crear una línea mediante la clase LineGeometry

En este ejemplo se muestra cómo utilizar la clase LineGeometry para describir una línea. Sus puntos inicial y final definen un elemento LineGeometry.

Ejemplo

En el ejemplo siguiente se muestra cómo crear y representar una LineGeometry. Se utiliza un elemento Path para representar la línea. Puesto que una línea no tiene área, no se especifica la propiedad Fill del objeto Path; en su lugar se utilizan las propiedades Stroke y StrokeThickness.

<Path Stroke="Black" StrokeThickness="1" >
  <Path.Data>
    <LineGeometry StartPoint="10,20" EndPoint="100,130" />
  </Path.Data>
</Path>
            Dim myLineGeometry As New LineGeometry()
            myLineGeometry.StartPoint = New Point(10,20)
            myLineGeometry.EndPoint = New Point(100,130)

            Dim myPath As New Path()
            myPath.Stroke = Brushes.Black
            myPath.StrokeThickness = 1
            myPath.Data = myLineGeometry
LineGeometry myLineGeometry = new LineGeometry();
myLineGeometry.StartPoint = new Point(10,20);
myLineGeometry.EndPoint = new Point(100,130);

Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
myPath.Data = myLineGeometry;

Objeto LineGeometry dibujado desde (10,20) hasta (100,130)

LineGeometry

Otras clases de geometrías simples son LineGeometry y EllipseGeometry. Estas geometrías, así como otras complejas, también se pueden crear utilizando una clase PathGeometry o StreamGeometry. Para obtener más información, vea Información general sobre geometría.

Vea también

Tareas

Cómo: Crear una forma compuesta

Cómo: Crear una forma mediante una clase PathGeometry

Conceptos

Información general sobre geometría