Reputation: 667
When I create a menu in XAML like this:
<Menu>
<MenuItem Height="auto" Header="{x:Static str:StringResources.File}">
<MenuItem Header="{x:Static str:StringResources.Open}"
InputGestureText="Ctrl+O"
Command="{Binding OpenFileCommand}"/>
<MenuItem Header="{x:Static str:StringResources.Save}"
InputGestureText="Ctrl+S"
Command="{Binding SaveFileCommand}"/>
<MenuItem Header="{x:Static str:StringResources.SaveAs}"
InputGestureText="Ctrl+Shift+S"
Command="{Binding SaveAsFileCommand}"/>
<MenuItem Header="{x:Static str:StringResources.Exit}"
InputGestureText="Alt+F4"
Click="MenuItemExit_Click"
/>
</MenuItem>
</Menu>
The menu is folded out with the edge of the menu right-aligned to the edge of the top menu item (File in this case). This means that the menu looks like this:
_____________________________________________
__________________|____|File|_____________________________-|_|X|
| | Open Ctrl+O| |
| | Save Ctrl+S| |
| | Save As.. Ctrl+Shift+S| |
| | Exit Alt+F4| |
This looks ugly, especially on non-maximized windows, where the folded-out menu will be drawn outside of the window for a large part.
I want it to look like this:
_______________________________________________________________
|File|____________________________________________________|-_X|
| | Open Ctrl+O| |
| | Save Ctrl+S| |
| | Save As.. Ctrl+Shift+S| |
| | Exit Alt+F4| |
I've been trying to find out how to change this, but I couldn't find anything. I've tried things like HorizontalAlignment, HorizontalContentAlignment, but that does not work.
Also, I've noticed this menu orientation only with Windows 7, not with Windows XP. Lastly, this menu orientation is also in Visual Studio 2010 Express!
If any of you could provide me with an answer or a direction to search, I'd be very grateful.
Upvotes: 3
Views: 4139
Reputation: 848
This happens in a machine with touch screen. On the start Menu Click:
Tablet PC Settings
Open the "Other" tab.
Change from "Right-Handed" to "Left-Handed"
Upvotes: 0
Reputation: 341
You have to change an entry in your registry.
The solution was posted here: WPF Sub-MenuItem Opening on the Left Instead of the Right
Upvotes: 0
Reputation: 333
It seems to be a configuration problem with your local windows machine (check if this behavior appears in other programs too). If yes, you have two possibilities to fix this:
Choice 1
Your menus should open left-aligned.
Choice 2
Upvotes: 5
Reputation: 81313
Try declaring the itemsPanelTemplate for the Menu like this -
<Menu>
<Menu.ItemsPanel>
<ItemsPanelTemplate>
<DockPanel HorizontalAlignment="Left"/>
</ItemsPanelTemplate>
</Menu.ItemsPanel>
<MenuItem Height="auto" Header="{x:Static str:StringResources.File}">
<MenuItem Header="{x:Static str:StringResources.Open}"
InputGestureText="Ctrl+O"
Command="{Binding OpenFileCommand}"/>
<MenuItem Header="{x:Static str:StringResources.Save}"
InputGestureText="Ctrl+S"
Command="{Binding SaveFileCommand}"/>
<MenuItem Header="{x:Static str:StringResources.SaveAs}"
InputGestureText="Ctrl+Shift+S"
Command="{Binding SaveAsFileCommand}"/>
<MenuItem Header="{x:Static str:StringResources.Exit}"
InputGestureText="Alt+F4"
Click="MenuItemExit_Click"
/>
</MenuItem>
</Menu>
Upvotes: 0
Reputation: 45068
You might try looking into FlowDirection
, information at this MSDN page:
<MenuItem FlowDirection="LeftToRight">
</MenuItem>
Upvotes: 1