Compartir a través de


Cómo: Crear varios subtrazados en un PathGeometry

Actualización: noviembre 2007

Este ejemplo muestra cómo crear varios subtrazados en un PathGeometry. Para crear varios subtrazados, se crea una figura PathFigure para cada uno de ellos.

Ejemplo

En el ejemplo siguiente se crean dos subtrazados, cada uno es un triángulo.

<Path Stroke="Black" StrokeThickness="1">
  <Path.Data>
    <PathGeometry>
      <PathGeometry.Figures>
        <PathFigureCollection>
          <PathFigure IsClosed="True" StartPoint="10,100">
            <PathFigure.Segments>
              <PathSegmentCollection>
                <LineSegment Point="100,100" />
                <LineSegment Point="100,50" />
              </PathSegmentCollection>
            </PathFigure.Segments>
          </PathFigure>
          <PathFigure IsClosed="True" StartPoint="10,10">
            <PathFigure.Segments>
              <PathSegmentCollection>
                <LineSegment Point="100,10" />
                <LineSegment Point="100,40" />
              </PathSegmentCollection>
            </PathFigure.Segments>
          </PathFigure>                    
        </PathFigureCollection>
      </PathGeometry.Figures>
    </PathGeometry>
  </Path.Data>
</Path>

En el ejemplo siguiente se muestra cómo crear varios subtrazados mediante Path y la sintaxis de atributo de XAML. Cada M crea un nuevo subtrazado para que el ejemplo cree dos subtrazados, cada uno de los cuales dibuja un triángulo.

<Path Stroke="Black" StrokeThickness="1" 
  Data="M 10,100 L 100,100 100,50 Z M 10,10 100,10 100,40 Z" />

(Tenga en cuenta que, en realidad, esta sintaxis de atributo crea un objeto StreamGeometry, que es una versión ligera de PathGeometry. Para obtener más información, consulte la página Sintaxis de marcado de trazados.)

Vea también

Conceptos

Información general sobre geometría