views:

116

answers:

1

I have a Path that must resize to its StackPanel container.

<StackPanel x:Name="TrackSurface">
    <Path Fill="AliceBlue"
          Stroke="Black" StrokeThickness="1"
          Data="{StaticResource TranslateZ}">
    </Path>
</StackPanel>

I think about using a transformation bound to the container but don't know how to it actually. Can someone give me hint?

A: 

I changed the Stackpanel to Grid and Stretch property of the Path to Fill.

<Grid x:Name="TrackSurface"> 
<Path Fill="AliceBlue" 
Stretch="Fill"
      Stroke="Black" StrokeThickness="1" 
      Data="M148,28 C221,133 110.50025,119.5 110.50025,119.5 L124.50016,68.5 z"> 
</Path> 

Kishore Kumar
Thanks Kishore. It doesn't work in my case. I have a Grid with a UserControl in a row, the Path is in the UserControl. It must not extend the column width. This is why I used a StackPanel. I've overriden OnRenderSizeChanged in the UserControl to maintain an aspect ratio of 1. So the Path needs to fill a squared UserControl which size is the column width. Not sure I'm clear. With your solution, the column width extend to match the original bouding box of the Path.
742