In WPF I have Window with some buttons. Currently I have this functionality: I click a button and the Popup pops underneath the button.
My goal is when dragging main Window the Popup to move with the Window so Popup remains under the button.
Currently I'm using this code, but it seems it's not working - Popup pops, but when dragging main Window the Popup stays in the same place.
Here is my code:
private void Window_LocationChanged(object sender, EventArgs e)
{
ResetPopUp();
}
private void ResetPopUp()
{
var offsetHor = popup.HorizontalOffset;
var offsetVer = popup.VerticalOffset;
popup.HorizontalOffset = offsetHor + 1;
popup.HorizontalOffset = offsetHor - 1;
popup.VerticalOffset = offsetVer + 1;
popup.VerticalOffset = offsetVer - 1;
}
I will be thankfully for any answers!