WPF Clipping Problem

半城伤御伤魂 提交于 2019-12-17 21:17:52

问题


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 this problem? I hope I explained my problem understandable ;)


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/2163079/wpf-clipping-problem

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!