WPF:缩放路径的正确方法? [英] WPF: the right way to scale a path?

查看:31
本文介绍了WPF:缩放路径的正确方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一条路径(看起来像一个椭圆):

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)

推荐答案

另一种缩放路径的方法是使用 RenderTransformLayoutTransform

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>

这篇关于WPF:缩放路径的正确方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆