Aligning Menu Items Correctly in WPF

Is it possible to align menu items correctly in WPF?

Thanks Sharath

+1


a source to share


3 answers


<Menu HorizontalAlignment="Stretch" FlowDirection="RightToLeft">            
        <MenuItem HorizontalAlignment="Right" Header="aaa">
        </MenuItem>
        <MenuItem HorizontalAlignment="Right" Header="bbb">
        </MenuItem>
</Menu>

      



+3


a source


Yes, you can.

The implementation is a bit shy though.

If you want the menu items in the top menu to move from right to left, add FlowDirection = "RightToLeft" to your menu. If you want the item to be aligned in the dropdown, follow these steps:



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

      

If you want to do both, you really need to set HorizontalAlignment = "Left" instead of right, since the FlowDirection changes direction to the right and left in the settings. I don't know why, but this is what you need to do.

+2


a source


How to properly align a help menu item in WPF?

I like the second answer with a grid.

                                                                                                                                                                                                                                                          

+2


a source







All Articles