Shai UI
Shai UI

Reputation: 51978

WPF: how to make a path's size conform to its parent's size

Let's say in blend I take the pen tool and I just create a closed shape.

I'd like to then make this shape's width (or height) stretch to its container's dimensions.

So let's say I have

<Grid Width="500">
    <Path Data="Bla Bla" Width="200">
</Grid>

In other words, how can I make the path's width conform to its parent. I try to just go

<Canvas Width="500">
    <Path Data="Bla Bla" HorizontalAlignment="Stretch">
</Canvas>

but that doesn't work. it works with a rectangle but not with a path, so how can I do it with a path?

Upvotes: 6

Views: 2958

Answers (1)

Kent Boogaart
Kent Boogaart

Reputation: 178790

<Viewbox>
    <Path .../>
</Viewbox>

Upvotes: 5

Related Questions