需要知道用户何时调整窗口大小

发布于 2024-11-30 06:23:18 字数 419 浏览 4 评论 0原文

我在 Silverlight 中创建了一个用户控件,因此现在我可以在任何我想要的地方多次重复使用它。该控件也使用弹出窗口。当弹出窗口打开时,我以编程方式设置其位置,使其看起来像是锚定到控件上。但是,当此弹出窗口已经可见并且用户更改 Internet Explorer 窗口的大小时,页面内容会移动,而弹出窗口不会移动。 [显然。] 所以它看起来不再锚定在控件上。如何修复它?处理哪个事件?

我预计当用户更改窗口大小时会触发一些事件。或者甚至更好的是一个事件,它可以在重新定位所属控件时通知我,这样我就知道控件的新位置(我需要知道它才能计算弹出窗口的坐标)。因为我希望它作为用户控件工作,所以我更喜欢控件本身的本地事件(即不弄乱任何全局页面/窗口内容)。请帮助我找到合适的活动。

更新:在我看来,现在我确实需要知道所有权控件何时被移动。因为还可能有其他原因导致其移动(除了上述窗口大小的变化)。

I created a user control in Silverlight, so now I can siply reuse it multiple times anywhere I want. This control also uses a popup. When the popup is opened, I programatically set its position so it looks like anchored to the control. But when this popup is already visible and user changes size of Internet Explorer window, the contens of page are moved and the popup is not moved. [Obviously.] So it doesn't look like anchored to the control anymore. How to fix it? Which event to handle?

I expect there is some event which is fired when user changes size of the window. Or even better an event which can inform me when the owning control is repositioned, so I know the new position of the control (which I need to know in order to compute the coordinates for the popup). Since I want it to work as a user control, I would prefer a local event on the control itself (i.e. without messing with any global page/window stuff). Please help me to find the right event.

Update: It seems to me now that LITERALLY I need to know when the owning control is moved. Because there can also be other reasons why it's moved (other than abovementioned change of the window's size).

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

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

发布评论

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

评论(1

壹場煙雨 2024-12-07 06:23:18

我认为您正在寻找 SizeChanged 事件。您可以订阅该内容以了解何时调整弹出窗口的大小。

如果您的控件因另一个控件而移动,这可能没有帮助。由于它可能无法调整大小,因此只需将其安排在新位置即可。

如果出现问题,您可以使用 LayoutUpdated 确定元素内部是否发生任何更改。为此,您需要将处理程序附加到 RootVisual 或元素上方的其他内容。

I think you are looking for the SizeChanged event. You can subscribe to that to know when to resize your popup.

If your control is moved because of another control, this may not help though. As it may not resize, just be arranged in a new location.

If that's a problem, you can use the LayoutUpdated to determine if anything changed inside an element. For this you'd need to attach a handler to the RootVisual or something above your element.

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