WPF菜单项左对齐?

时间:2012-02-22 11:21:12

标签: wpf

enter image description here

我想在主菜单的右侧显示菜单项。目前它显示在左侧。

  <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>

1 个答案:

答案 0 :(得分:6)

这似乎是您本地Windows计算机的配置问题(检查此行为是否也出现在其他程序中)。如果是,您有两种可能来解决这个问题:

选择1

  • 赢+ R
  • 输入“shell ::: {80F3F1D5-FECA-45F3-BC32-752C152E456E}”,按确定
  • 在“其他”下右手改为左撇子,按确定

您的菜单应该左对齐。

选择2

  • 打开注册表并更改以下条目: [HKEY_CURRENT_USER \ Software \ Microsoft \ Windows NT \ CurrentVersion \ Windows \ MenuDropAlignment] 为“0”
  • 重新启动