开发者

WPF Clipping Problem

开发者 https://www.devze.com 2022-12-19 01:18 出处:网络
I have a UserControl which has a quadratic Image as a Child. This Image is at the bottom of the UserControl, and half of it is clipped (e.g. the Control\'s Height is 400, Image\'s height is 200 and it

I have a UserControl which has a quadratic Image as a Child. This Image is at the bottom of the UserControl, and half of it is clipped (e.g. the Control's Height is 400, Image's height is 200 and it is set to y=300).

Now, When I rotate the Image, it is still clipped like the way it was first. Like when rotating around 90 degrees, I suddenly have an Image which is only 100px wide.

It seems like the original clipping which was made because of the bounds of the UserControl, are applied forever.

How do I solve thi开发者_如何学Gos problem? I hope I explained my problem understandable ;)


How are you rotating the image? If you are rotating using a RenderTransform, then WPF does not re-render what was already displayed on the screen - it simply rotates the pixels.

Instead, rotate the image using a LayoutTransform; this forces WPF to re-render the control given the new area it occupies, which should eliminate the clipping you see.


You can also call InvalidateMeasure() after applying render transform.

0

精彩评论

暂无评论...
验证码 换一张
取 消