2011-02-17 58 views
1

我試圖找到在PathGeometry中使用的IsFilled="False"的等效項,但對於Path Mini對於路徑迷你語言(Silverlight/WPF)中的PathFigure,IsFilled =「false」的等效

left is Path Mini and right is PathGeometry

可以看到,下面的兩個路徑是相同的,除了一個與幾何形狀具有在所述第二<PathGeometry>.<PathGeometry.Figures>.<PathFigure>IsFilled="False"。這是所需的行爲,但我希望將它用於Path Mini(即在第一個<Path>中)。我瀏覽過文檔,似乎無法找到任何內容,因爲看起來Path Mini不是數字的集合。

據我所知,所有形狀/幾何圖形在運行時都會轉換爲迷你路徑,那麼是否有一些方法可以反映已編譯的XAML以查看解釋器如何將PathGeometry渲染爲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> 

回答

2

路徑迷你語言只支持輪廓,所以筆畫必須轉換爲填充。如果你想要一個像素寬的線條,並且你對於斜面或者端蓋不是太挑剔,這很簡單。只需使用瘦小的矩形。使用最少點數和處理交叉點的無限窄行程的真正數學「增長」比較困難。不過,你可能可以使用WPF渲染引擎爲你做這件事,因爲顯然它已經可以做到了。

+0

謝謝瑞克。接受,因爲它似乎是唯一的答案。你知道迷你路徑上的任何文檔比我上面提供的鏈接更詳細嗎? – 2011-02-18 19:36:15