Popup from code behind in WPF not working ( On resize and switching windows) Popup from code behind in WPF not working ( On resize and switching windows) wpf wpf

Popup from code behind in WPF not working ( On resize and switching windows)


you have to tell the popup to display itself, too.

codePopup.IsOpen = true;

see this blog for a bit more info.

[EDIT]
basically, your popup is not "tied" (or "owned") by any parent, it is independent of any other window and/or control (etc.) Unfortunatly, there is not any easy way to get around this.

You should probably download the Popup Position Sample from MSDN here.

The code sample uses the class CustomPopupPlacement with a Rect object, and binds to horizontal and vertical offsets to move the Popup.


If you want popup should close automatically when you click outside of it then set codePopup.StaysOpen = false.So that it will close when you click outside of it.