在主窗口的边界处剪辑 wpf 弹出窗口
据我了解,弹出窗口存在于它自己的视觉树中。 但是,我注意到一些属性,Clip 和 ClipToBounds。 我想要做的是在窗口的右边缘和下边缘视觉上剪辑弹出窗口,而不管弹出窗口独立于窗口的边界。 我没有使用 XAML,但如果有人知道如何在 XAML 中执行此操作,那就没问题了。 我可以使用 System.Windows.Application.Current.MainWindow 进入主窗口。 是否可以从中获取可用于剪辑弹出窗口的值? 我假设如果有一个我可以使用的值,那么我将能够将弹出窗口的剪辑绑定到该值。 这实际上是没有必要的,因为在弹出窗口最初打开后,如果窗口被移动或调整大小,弹出窗口将关闭。 所以我真的只需要在弹出窗口打开时对其进行剪辑。 我想这样做的原因是因为虽然我使用的是弹出窗口,但我不希望它显示为存在于窗口外部的弹出窗口。 仅供参考,这是自定义日期框的弹出日历。 任何想法以及对我可能有的误解的澄清,将不胜感激。
From what I understand, the popup exists within it's own visual tree. However, I've noticed a few properties, Clip and ClipToBounds. What I am wanting to do is Visually clip a popup at the right and bottom edges of a window regardless of the fact that the popup is independent of the bounds of the window. I'm not using XAML, but if somebody knows how to do it in XAML, then that's fine. I can get to the main window using System.Windows.Application.Current.MainWindow. Is it possible from this to get a value that I can use to clip the popup? I'm assuming that if there is a value that I can use, then I would be able to bind the clipping of the popup to that value. This is really not necessary since after the popup initially opens, if the window gets moved or resized, the popup closes. So I would really only need to clip the popup when it opens. The reason I would like to do this is because although I am using a popup, I don't want it to appear as a popup that exists outside of the window. FYI this is for a popup calendar for a custom datebox. Any ideas, as well as clarification of misconceptions that I may have, would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此外,可以从不直接位于主窗口上的用户控件启动弹出窗口。 所以在这种情况下,使用弹出窗口会更容易。 与 XAML 内的 UC 不同
Furthermore, the popup can be launched from a user control that is not directly on the Main Window. So in that case it would be easier to use a popup. As apposed to a UC inside the XAML
我知道这是一篇已有一年的帖子,但万一其他人来这里寻找答案......如果您不需要弹出窗口位于窗口之外,为什么要使用弹出窗口呢? 简单地使用画布中的控件(例如)并通过其 Visibility 属性控制它会容易得多。 然后你就会自动得到你的剪辑。
I know this is a year old post, but in case any others come here looking for answers... If you don't need the popup to be outside of your window, why use a popup at all? It'd be far easier to simply use a control in a canvas (for instance) and control it via its Visibility property. Then you'd automagically get your clipping.