2

Can i right align the menu items in WPF?

Thanks Sharath

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72

3 Answers3

3
<Menu HorizontalAlignment="Stretch" FlowDirection="RightToLeft">            
        <MenuItem HorizontalAlignment="Right" Header="aaa">
        </MenuItem>
        <MenuItem HorizontalAlignment="Right" Header="bbb">
        </MenuItem>
</Menu>
ahaliav fox
  • 2,217
  • 22
  • 21
3

How do I right-align the 'help' menu item in WPF?

I like the second answer with the grid way.

Community
  • 1
  • 1
Frederic
  • 760
  • 1
  • 5
  • 15
3

Yes, you can.

Although the implementation is a little screwy.

If you want to have the menu items in the top menu go from right to left, add FlowDirection="RightToLeft" to your Menu. If you want to have an item aligned right in a dropdown, do the following:

<MenuItem>
    <MenuItem.Header>
        <TextBlock HorizontalAlignment="Right" >Content</TextBlock>
    </MenuItem.Header>
</MenuItem>

If you want to do both, you actually have to set HorizontalAlignment="Left" instead of right, as the FlowDirection reverses the right and left in the Alignments. I don't know why, but that's what you have to do.

Drew McGhie
  • 1,086
  • 1
  • 12
  • 26
  • 1
    Isn't it wonderful when you find out that one solution screws up another? Seriously, try making a menu with the FlowDirection="RtL" and aligning things right, they all go left! – Drew McGhie May 14 '09 at 16:29