裁剪变换在WPF? [英] Crop transform in WPF?

查看:161
本文介绍了裁剪变换在WPF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WPF允许使用 <$ C $的子类C>变换 规模(的 ScaleTransform ),旋转(的 RotateTransform ),歪斜(的 SkewTransform )等任何的 FrameworkElement的

WPF allows to use subclasses of Transform to scale(ScaleTransform), rotate(RotateTransform), skew (SkewTransform) and so on any FrameworkElement.

但我不能看到如何进行一些裁剪 FrameworkElement的 使用这些。有什么办法如何裁剪可以说的标签宽度30像素,因此将像它的宽度为20像素?

But I cannot see how to crop some FrameworkElement using these. Is there any way how to crop lets say a Label of width 30px so it will behave as if its width was 20px?

要更确切的说:我想这样做铺设之前,使标签将布局为如果它的宽度为20。但我希望它是呈现充分所以最后10个像素也将被渲染(可能是重叠的其他元素)。我怎样才能做到这一点?

To be more exact: I want to do this before laying out so that the Label would be laid out as if its width was 20. But I want it to be rendered fully so the last 10 pixels will be rendered too (possibly overlapping other elements). How can I do this ?

为什么我需要这个?我想打<一个href="http://stackoverflow.com/questions/5796457/create-guitar-chords-editor-in-wpf-from-richtextbox/5797833#5797833">H.B.'s回答我的问题<一href="http://stackoverflow.com/questions/5796457/create-guitar-chords-editor-in-wpf-from-richtextbox">Create在WPF吉他和弦编辑,提供字距

Why do I need this ? I want to make H.B.'s answer to my question Create guitar chords editor in WPF to work with kerning.

推荐答案

使用负保证金标签上,如保证金=0,0,-10,0使标签10像素右侧短,布局明智的。 (为prevent重叠把它放在一个容器中,并设置 ClipToBounds =真

Use a negative Margin on the label, e.g. Margin="0,0,-10,0" makes the Label 10 pixels shorter on the right, layout-wise. (To prevent overlap put it in a container and set ClipToBounds="True")

这篇关于裁剪变换在WPF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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