Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF: the right way to scale a path?

Tags:

c#

wpf

xaml

I have a path (looks like an oval):

<Path Data="Bla Bla"/> 

Now I want to scale the path's width and height to whatever I like. I found a way:

<Grid Width="400" Height="50"> <Viewbox Stretch="Fill">     <Path Data="Bla Bla"/> </Viewbox>   </Grid> 

And this works, but I'm wondering if this is the most efficient way to do this? (I had to introduce a grid and viewbox to do this)

like image 735
Shai UI Avatar asked Feb 24 '11 18:02

Shai UI


1 Answers

Another way to Scale a Path is to use RenderTransform or LayoutTransform

<Path Data="Bla Bla"       RenderTransformOrigin="0.5, 0.5">     <Path.RenderTransform>         <ScaleTransform ScaleX="1.5" ScaleY="1.5"/>     </Path.RenderTransform> </Path> 
like image 118
Fredrik Hedblad Avatar answered Oct 04 '22 20:10

Fredrik Hedblad