Silverlight 中的缩放控件会缩小控件,但不会缩小其占用的空间
我注意到,如果我在 Silverlight 控件上使用 ScaleTransform,它会缩小控件的可见部分,但不会缩小它所占用的空间(即其边界框)。
无论如何,是否可以覆盖此行为,以便在应用 ScaleTransform 时控件和边界框都缩小?或者还有其他方法来缩小 UserControl 吗?如果我只是通过调整高度/宽度来缩小它,很多细节就会消失(它们不能正确消除锯齿)。
(注意:我在 Expression Blend 中观察到这种行为,但我认为它通常适用于 Silverlight/WPF 控件。)
出于上下文考虑,我尝试通过将 UserControl 放置在 Button 内来制作图像按钮。我正在将 UserControl 转换为 X = 0.15 & Y = 0.15。 UserControl 正确收缩,但 Button 看起来有很大的填充,因为 UserControl 的边界框不会相应收缩。我可以将 ScaleTransform 应用于整个按钮,但是按钮具有巨大的边界框,这会产生其他问题。
I'm noticing that if I use a ScaleTransform on a control is Silverlight, it shrinks the visible aspects of the control, but not the space it occupies (i.e., its bounding box).
Is there anyway to override this behavior so that the control and the bounding box both shrink when I apply a ScaleTransform? Or is there some other way to shrink a UserControl? If I just plain shrink it by adjusting Height/Width, a lot of the details disappear (they don't anti-alias properly).
(Note: I'm observing this behavior in Expression Blend, but I assume it applies to Silverlight/WPF controls in general.)
For the sake of context, I'm trying to make an image button by placing a UserControl inside a Button. I'm transforming the UserControl to X = 0.15 & Y = 0.15. The UserControl shrinks properly, but the Button looks like it has a massive padding on it because the UserControl's bounding box doesn't shrink accordingly. I could apply the ScaleTransform to the whole button, but then it's the button that has the huge bounding box, and this creates other problems.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用
LayoutTransform
而不是RenderTransform
。由于 Silverlight 不支持开箱即用,因此您可以从 Silverlight 获取LayoutTransformer
控件工具包将允许您执行此操作。您的代码将如下所示:
You need to use a
LayoutTransform
and not aRenderTransform
. Since it isn't supported out of the box with Silverlight, you can get aLayoutTransformer
control from the Silverlight Toolkit that will allow you to do this.Your code would then look like so: