WPF 路径大小调整
这是我的路径:
<Style x:Key="MyPath" TargetType="{x:Type Path}">
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="Stroke" Value="Blue" />
<Setter Property="Data" Value="M0,100 L 80,40 160,100 M 40,80 L 40,160 120,160 120,80" />
</Style>
<Path Style="{StaticResource MyPath}">
<Path.RenderTransform>
<ScaleTransform ScaleX="0.3"
ScaleY="0.3" />
</Path.RenderTransform>
</Path>
这会缩放图像,这很好。
问题在于,缩放后路径周围的空白区域(具有原始路径大小的大小)仍然可见。设置路径的宽度和高度并不能解决问题,因为设置高度会导致图像被剪切,但空白仍然保留在那里。
为了清楚起见,我添加了一张图片:
alt text http://img190.imageshack.us /img190/5923/problemis.png
有什么帮助吗?谢谢
This is my Path:
<Style x:Key="MyPath" TargetType="{x:Type Path}">
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="Stroke" Value="Blue" />
<Setter Property="Data" Value="M0,100 L 80,40 160,100 M 40,80 L 40,160 120,160 120,80" />
</Style>
<Path Style="{StaticResource MyPath}">
<Path.RenderTransform>
<ScaleTransform ScaleX="0.3"
ScaleY="0.3" />
</Path.RenderTransform>
</Path>
This scales the image, which is good.
The problem is that the white space around the path (with the size of the original Path size) stays visible after the scaling. Setting the Path's Width and Height does not solve the problem because setting the Height for example causes the image to be cut, but the white space still stays there.
I'm adding an image for clarity:
alt text http://img190.imageshack.us/img190/5923/problemis.png
Any help? Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 LayoutTransform 而不是 RenderTransform。
ScotLogic 博客 - LayoutTransform 与 LayoutTransform RenderTransform
“当应用 LayoutTransform 时,相邻元素会重新定位以适应变换后的元素,而使用 RenderTransform 时则不会。”
Try LayoutTransform instead of RenderTransform.
ScotLogic blog - LayoutTransform vs. RenderTransform
"When a LayoutTransform is applied, neighbouring elements are re-positioned to accommodate the transformed elements, whereas with the RenderTransform they are not."