0

for only 1 right-aligned menu item I have found this solution:

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

Is there a solution if I want more than 1 menu item right-aligned:

Program | View |                            Edit | File | ...

Thank you in advance!

Community
  • 1
  • 1
GrayFox
  • 997
  • 1
  • 9
  • 26

1 Answers1

0

This answer which you link does in fact have almost the solution.

The key resides in the ItemPanelTemplate HorizontalAlignement property!

<Menu HorizontalAlignment="Stretch" VerticalAlignment="Top">
    <Menu.ItemsPanel>
        <ItemsPanelTemplate>
            <DockPanel HorizontalAlignment="Right"/>
        </ItemsPanelTemplate>
    </Menu.ItemsPanel>
    <MenuItem Header="File"/>
    <MenuItem Header="Edit"/>
</Menu>

However, if you indeed want 2 or mores items to the left AND to the right, you will need some hacky solutions like this one, which requires the number of items to be constant.

Community
  • 1
  • 1
Kilazur
  • 3,089
  • 1
  • 22
  • 48