Hello,
I've been beating my head against a WPF Popup issue, and am hoping someone can help me:) The outline goes like this:
Our app stores a list of UIObjects - these represent elements that are displayed in a viewport 3d (via a member UIRenderObject, which is just a flat, square mesh with a bitmap on it) and in a treeview (via a member TreeViewItem).
In either case, when the object detects a right click, it tries to open a popup. The code for that is about as straight forward as you can get:
ContextMenu contextMenu = new ContextMenu();
//add content
contextMenu.IsOpen = true;
When I click in the viewport, everything works as expected - the popup opens, and stays open until it loses focus or a selection is made. In the tree-view, however, the popup loses focus and closes immediately.
I've tried explicitly setting focus, explicitly setting the PlacementTarget, marking the mouse event as handled before and after the call to open the popup, flat-out marking the popup as "StaysOpen" and a dozen other things, and still it closes immediately.
Any help will be much appreciated. Thanks in advance!