Equivalent of IsFilled="false" for PathFigure in Path Mini-language (Silverlight/WPF)

541 views Asked by At

I'm trying to find the equivalent of IsFilled="False" that is used in a PathGeometry, but for Path Mini.

left is Path Mini and right is PathGeometry

You can see that the two paths below are identical, except for the one with geometries has IsFilled="False" in the second <PathGeometry>.<PathGeometry.Figures>.<PathFigure>. This is the desired behavior, but I'd like to have it for a Path Mini (i.e. in the first <Path>). I've looked through the documentation and can't seem to locate anything on it as it appears that Path Mini is not a collection of figures.

As I understand it, all shapes/geometries will get converted to path mini at run-time, so is there some way to reflect the compiled XAML to see how the interpreter renders the one with PathGeometry to Path Mini?

<Canvas Background="#FDB" Width="800" Height="600">

  <!-- this is the LEFT-HAND Path in the picture above -->
  <Path Canvas.Left="100" Canvas.Top="100"
     Stroke="#385D8A" StrokeThickness="2" StrokeLineJoin="Round" Fill="#4F81BD"
     Data="M0,0L102,0L102,102L0,102Z M46.15,49.01L-73.36,130.99L-96.42,-96.12L109.35,355.18">
  </Path>

  <!-- this is the RIGHT-HAND Path in the picture above -->
  <Path Canvas.Left="300" Canvas.Top="100" Stroke="#385D8A" StrokeThickness="2" StrokeLineJoin="Round" Fill="#4F81BD">
    <Path.Data>
      <GeometryGroup>
        <PathGeometry>
          <PathGeometry.Figures>
            <PathFigure StartPoint="0,0" IsClosed="True">
              <PathFigure.Segments>
                <LineSegment Point="102,0" />
                <LineSegment Point="102,102" />
                <LineSegment Point="0,102" />
              </PathFigure.Segments>
            </PathFigure>
          </PathGeometry.Figures>
        </PathGeometry>
        <PathGeometry>
          <PathGeometry.Figures>
            <PathFigure IsFilled="False" StartPoint="46.15,49.01">
              <PathFigure.Segments>
                <LineSegment Point="-73.36,130.99" />
                <LineSegment Point="-96.42,-96.12" />
                <LineSegment Point="109.35,355.18" />
              </PathFigure.Segments>
            </PathFigure>
          </PathGeometry.Figures>
        </PathGeometry>
      </GeometryGroup>
    </Path.Data>
  </Path>
</Canvas>
1

There are 1 answers

1
Rick Sladkey On BEST ANSWER

The path mini-lanuage only supports outlines so strokes must be converted to fills. This is straightforward to do yourself if you want one-pixel wide lines and you aren't too fussy about mitering or endcaps. Just use skinny rectangles. A true mathematical "grow" of an infinitely narrow stroke using the minimum number of points and handling crossings is quite a bit harder. However you might be able to use the WPF rendering engine to do that for you since obviously it can already do it.