Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Menuitems align left?

Tags:

wpf

enter image description here

I want to display the menuitems to the right side of the Main menu. Currently its displayed to the left.

  <Menu Name="menu1" Width="800" Margin="0,0,0,670">
        <MenuItem Header="File">
            <MenuItem Header="Open"/>
            <MenuItem Header="Close"/>
        </MenuItem>
        <MenuItem Header="Edit"/>
    </Menu>


 <Style TargetType="{x:Type MenuItem}">
        <Setter Property="MinHeight" Value="30" />
        <Setter Property="MinWidth" Value="100"/>
        <Setter Property="HeaderTemplate">
            <Setter.Value>
                <DataTemplate>
                    <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"  Content="{Binding}" />                       
                </DataTemplate>                    
            </Setter.Value>               
        </Setter>
        <Setter Property="Background" Value="Yellow" />
        <Setter Property="BorderBrush" Value="Black" />
        <Setter Property="BorderThickness" Value="1" />
    </Style>
like image 569
sony Avatar asked Feb 16 '26 13:02

sony


1 Answers

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

  • Win+R
  • Enter "shell:::{80F3F1D5-FECA-45F3-BC32-752C152E456E}", press Ok
  • Under "Other" change Right-Handed to Left-Handed, press Ok

Your menus should open left-aligned.

Choice 2

  • Open your registry and change the following entry: [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\MenuDropAlignment] to "0"
  • Reboot
like image 110
Lukas Elmer Avatar answered Feb 18 '26 08:02

Lukas Elmer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!