<p>I have a program in which a new context menu is initialized in the very beginning of the program as a state variable.</p>
<p>In the class constructor, I add a few items to the menu.</p>
<p> </p>
<p>// initialize sector context menu</p>
<p>sectorContextMenu = new ContextMenu();</p>
<p>MenuItem menuItem1 = new MenuItem();</p>
<p>menuItem1.Header = "Sector Config";</p>
<p>menuItem1.Click += new RoutedEventHandler(ShowSectorConfig);</p>
<p>sectorContextMenu.Items.Add(menuItem1);</p>
<p> </p>
<p>Then, in an on left click function, I have this menu shown via sectorContextMenu.IsOpen = true.</p>
<p>The first left click shows the menu at the mouse position X. Second and subsequent clicks cause the menu to hide and then be displayed again at the original mouse position X (not the new one).</p>
<p> </p>
<p>If I cause the menu to be hidden permanently by clicking and dragging the mouse (in which case I have it set up so that the menu does not show up) then the subsequent click opens the menu at the mouse position Z. But second and subsequent clicks cause the menu to hide and then be displayed again at mouse position Z (not the new one).</p>
<p> </p>
<p>Please fix this bug or tell me what to do to avoid it.</p>
Comments: ** Comment from web user: DanielGS **
<p>In the class constructor, I add a few items to the menu.</p>
<p> </p>
<p>// initialize sector context menu</p>
<p>sectorContextMenu = new ContextMenu();</p>
<p>MenuItem menuItem1 = new MenuItem();</p>
<p>menuItem1.Header = "Sector Config";</p>
<p>menuItem1.Click += new RoutedEventHandler(ShowSectorConfig);</p>
<p>sectorContextMenu.Items.Add(menuItem1);</p>
<p> </p>
<p>Then, in an on left click function, I have this menu shown via sectorContextMenu.IsOpen = true.</p>
<p>The first left click shows the menu at the mouse position X. Second and subsequent clicks cause the menu to hide and then be displayed again at the original mouse position X (not the new one).</p>
<p> </p>
<p>If I cause the menu to be hidden permanently by clicking and dragging the mouse (in which case I have it set up so that the menu does not show up) then the subsequent click opens the menu at the mouse position Z. But second and subsequent clicks cause the menu to hide and then be displayed again at mouse position Z (not the new one).</p>
<p> </p>
<p>Please fix this bug or tell me what to do to avoid it.</p>
Comments: ** Comment from web user: DanielGS **
I have the same problem. Does anybody get a way to avoid it?