I search for a solution to the following problem: For a nice look I use a borderless window, so I have created a title area for this window (it's a Grid
).
<Grid x:Name="rootGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{DynamicResource BackgroundColor}" >
<Grid.ContextMenu>
<ContextMenu>
<MenuItem x:Name="cmiVerschieben" Header="Verschieben" Click="cmiVerschieben_Click"/>
</ContextMenu>
</Grid.ContextMenu>
<!-- ... -->
</Grid>
Now I added a context menu to the title bar like the most applications have (Close, Maximize, Minimize, Move ...).
The simple commands are not a problem, but for the "Move"-Entry I have to move my mouse cursor from the current position to the center of my title grid.
I tried it in cmiVerschieben_Click
with rootGrid.Focus();
and rootGrid.CaptureMouse();
, but both don't set my cursor to the rootGrid
.
Why I want to do this? In many other applications when I click the "Move" context menu item, the mouse is moved to the center of the title window.
I removed the unnecessary event handler from my code here.