Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Right Align MenuItems in WPF

Can i right align the menu items in WPF?

Thanks Sharath


2 Answers

<Menu HorizontalAlignment="Stretch" FlowDirection="RightToLeft">            
        <MenuItem HorizontalAlignment="Right" Header="aaa">
        </MenuItem>
        <MenuItem HorizontalAlignment="Right" Header="bbb">
        </MenuItem>
</Menu>
like image 153
ahaliav fox Avatar answered Dec 10 '25 08:12

ahaliav fox


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.

like image 45
3 revsDrew McGhie Avatar answered Dec 10 '25 09:12

3 revsDrew McGhie