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).
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.