如何确保 WPF UserControl 元素在控件边界之外可见?

发布于 2024-09-28 19:25:52 字数 424 浏览 7 评论 0原文

我有一个包含网格内交互式元素的用户控件。用户可以移动这些元素并调整其大小,这通常会导致它们超出我的控制范围。当元素确实落在外面时,我不希望它们被夹住。无论如何,我希望它们是可见的。不幸的是,将 ClipToBounds 设置为 FALSE 并没有解决问题。

即使在过去类似的情况下,我也使用过 ClipToBounds,虽然它一开始似乎有效,但我注意到当拖动到某些位置时,越界元素偶尔会消失。对于它们消失的原因似乎没有一个合乎逻辑的解释,除了布局系统可能优先考虑将 ClipToBounds 设置为 false,仅在某些位置。

这非常烦人,我的解决方法涉及以编程方式不断调整 UserControl 的大小以包含所有内部元素,这似乎是一种非常糟糕的方法。有没有一种更干净的方法来确保我的元素在控件边界之外始终可见(最好不使用 ClipToBounds - 是否有我在这里缺少的属性)?非常感谢任何帮助。

I have a UserControl containing interactive elements within a grid. The user can move and resize these elements, often causing them to fall outside the bounds of my control. When elements do fall outside, I don't want them to clip. I want them to be visible no matter what. Unfortunately, setting ClipToBounds to FALSE did not solve the problem.

Even in the past during a similar situation, I had used ClipToBounds, and while it appeared to work at first, I noticed that out-of-bounds elements occasionally disappeared when dragged to certain locations. There didn't seem to be a logical explanation as to why they disappeared except that perhaps the layout system was out-prioritizing ClipToBounds being set to false, only at certain locations.

It was very annoying and my work-around involved programmatically resizing my UserControl constantly to encase all inner elements, which seems to be a very bad approach. Is there a cleaner way to ensure that my elements are always visible outside the bounds of my control (preferably without using ClipToBounds - is there a property I'm missing here)? Any help is greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枯叶蝶 2024-10-05 19:25:52

AFIK Canvas 不夹...

AFIK Canvas do not clip...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文