用户控件消失而不是在 RotateTransform 下转动
我的 RotateTransform
行为有问题。
我在Grid
内有一个用户控件,它旋转了-135°,但是当我将该形状移动到Grid
的限制时,它开始消失,起作用就像它没有旋转一样。我该如何解决这个问题?
替代文本 http://img522.imageshack.us/img522/6241/cenask.jpg< /a>
I'm having problems with RotateTransform
behavior.
I have a user control inside a Grid
and it's rotated -135º, but when I move that shape to the limits of the Grid
, it starts to disappear, acting like it has no rotation. How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您的描述来看,我想说
UserControl
被Grid
的边界剪切,这是预期的默认行为。您可以在Grid
上设置ClipToBounds
属性,以确保在其外部运行的任何内容都不会被剪切。例如,请考虑以下情况:
这会导致:
alt text http://img514.imageshack .us/img514/8485/screenshotmf.png
将
ClipToBounds
更改为true
会导致:替代文本 http://img36.imageshack.us/img36/2682/screenshottz.png
Judging by your description, I'd say the
UserControl
is being clipped by the boundary of theGrid
, which is the expected default behavior. You can set theClipToBounds
property on yourGrid
to ensure any content that runs outside of it is not clipped.For example, consider the following:
This results in:
alt text http://img514.imageshack.us/img514/8485/screenshotmf.png
Changing
ClipToBounds
totrue
results in:alt text http://img36.imageshack.us/img36/2682/screenshottz.png
这可能是旋转应用位置的问题。
RotateTransform 有两个属性(CenterX、CenterY),用于确定旋转的点。
我引用 MSDN
它有可能围绕对象的左上角旋转,如果这是设置在底层画布的左上角,那么它将在画布空间之外旋转。
希望这有帮助
It might be an issue with where the rotation is being applied.
There is two properties on a RotateTransform (CenterX, CenterY) that determines the point at which to rotate around.
I quote from MSDN
It's possible that it's rotating around the top left of your object, and if thats the set to the top left of the underlying canvas, then it will rotate outside of your canvas space.
Hope this helps