wpf 中选定控件的边界矩形
有没有一种简单的方法来找到覆盖一组控件所需的矩形(区域和位置)? VisualTreeHelper.GetDecandentBounds() 工作正常,但没有重载方法可以让我指定在查找边界矩形时应考虑的控件。任何简单的解决方案将不胜感激。
谢谢
Is there a simple way to find the rectangle (area and location) that would be required to cover a set of control?? VisualTreeHelper.GetDescandentBounds() works fine, but there are no overloaded methods where I can specify the controls that it should consider for finding the bounds rectangle. Any simple solution will be greatly appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Rect 有一个
Union(Rect)
方法,该方法放大当前矩形以包含第二个矩形。使用 linq(不要忘记将using System.Linq;
添加到代码文件中),获取视觉效果列表的矩形列表也相当简单:编辑后的代码:它现在将占据考虑相对于给定视觉的个体视觉。
Rect has a
Union(Rect)
method, which enlarges the current rect to also include the second rectangle. With linq (dont forget to addusing System.Linq;
to your code file) it's also fairly simple to get a list of rectangles for a list of visuals:Edited code: It will now take the position of the individual visuals into account relative to the given visual.