I need to convert a shape to a path.
For example, a Rectangle with the height=67 and width="26"
<Rectangle x:Name="rect1" Height="67" Width="26" Canvas.Left="40" Canvas.Top="60" Fill="Teal" Stroke="Black" StrokeThickness="5"/>
Would be converted to
<Path x:Name="_260_rectangle_animation_1_polygon2base" Stroke="black" StrokeThickness="5" Fill="teal" Visibility="Visible">
<Path.Data>
<RectangleGeometry Rect="0 0 26 67">
<RectangleGeometry.Transform>
<MatrixTransform>
<MatrixTransform.Matrix>
<Matrix M11="1.0" M12="0" M21="0" M22="1" OffsetX="40" OffsetY="110" />
</MatrixTransform.Matrix>
</MatrixTransform>
</RectangleGeometry.Transform>
</RectangleGeometry>
</Path.Data>
</Path>
I run into a problem when the stroke has a large thickness, such as 5. The Path is showing a bigger rectangle. I realized the path doesn't outline the stroke, it follows the center of the stroke. So it always is the nubmer of StrokeThicknes pixels bigger. In my example, the width of the first rectangle is 26, the second one actually is 31.
Does any anyone know how to make the Path behave the same as the shape?
I know I could change the Rect to something Rect="0 0 21 67". But this is not what I am looking for.
thanks