2012-02-22 150 views
0

enter image description hereWPF Menuitems左對齊嗎?

我想將菜單項顯示在主菜單的右側。目前它顯示在左邊。

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

可能重複[如何更改菜單欄中menuitem的方向/位置](http://stackoverflow.com/questions/5687086/how-to-change-orientation-location-of-menuitem-i n-menubar) – 2012-02-22 11:29:52

+0

你能說清楚你在問什麼 - 你想把文件/編輯項目對齊到菜單欄的右邊還是把打開/關閉項目對齊到文件菜單項。 – 2012-02-22 11:30:12

+0

Hi Leom,我想打開/關閉文件菜單的右側 – sony 2012-02-22 11:31:24

回答

5

它似乎是您的本地Windows機器的配置問題(檢查此行爲是否也出現在其他程序中)。如果是的話,你有兩種可能解決這個問題:

選擇1

  • 贏+ R
  • 進入 「殼::: {80F3F1D5-FECA-45F3-BC32-752C152E456E}」,然後按確定
  • 在「其他」到左手,然後按確定

你的菜單應打開左對齊改變右手。

選擇2

  • 打開註冊表並更改以下條目: [HKEY_CURRENT_USER \軟件\微軟\的Windows NT \ CURRENTVERSION \的Windows \ MenuDropAlignment] 爲 「0」
  • 重啓
+0

謝謝,這幫助我與我的觸摸屏筆記本電腦。由於它是觸摸屏,因此設置爲使用菜單的右側顯示。 – 2013-09-08 22:20:15