Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fluent MenuItem does not align right. #10493

Open
Rijno opened this issue Feb 24, 2025 · 1 comment
Open

Fluent MenuItem does not align right. #10493

Rijno opened this issue Feb 24, 2025 · 1 comment

Comments

@Rijno
Copy link

Rijno commented Feb 24, 2025

Description

In plain old WPF, a MenuItem with HorizontalAlignment="Right" is aligned to the right of the menu bar. With Fluent, it does not do this anymore.

Default Fluent
Image Image

Reproduction Steps

App.xaml

<Application x:Class="TestWpfFluentMenuAlignment.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml" >
   <Application.Resources>
      <ResourceDictionary>
         <ResourceDictionary.MergedDictionaries>
            <!-- Load WPF Fluent theme (introduced in NET 9.0) -->
            <ResourceDictionary Source="pack://application:,,,/PresentationFramework.Fluent;component/Themes/Fluent.xaml" />
         </ResourceDictionary.MergedDictionaries>
      </ResourceDictionary>
   </Application.Resources>
</Application>

MainWindow.xaml

<Window x:Class="TestWpfFluentMenuAlignment.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
   <DockPanel>
      <Menu DockPanel.Dock="Top">
         <Menu.ItemsPanel>
            <ItemsPanelTemplate>
               <DockPanel HorizontalAlignment="Stretch"/>
            </ItemsPanelTemplate>
         </Menu.ItemsPanel>
         <MenuItem Header="_File">
            <MenuItem Header="New"/>
         </MenuItem>
         <MenuItem Header="_Help" HorizontalAlignment="Right">
            <MenuItem Header="About"/>
         </MenuItem>
      </Menu>

      <Grid></Grid>
   </DockPanel>
</Window>

Expected behavior

Aligns the MenuItem with HorizontalAlignment="Right" to the right of the menu bar.

Actual behavior

MenuItem with HorizontalAlignment="Right" remains aligned to the left.

Regression?

No response

Known Workarounds

No response

Impact

No response

Configuration

Which version of .NET is the code running on?
NET 9.0.200
What OS and version, and what distro if applicable?
Windows 10 19045.4291
What is the architecture (x64, x86, ARM, ARM64)?
x64
Do you know whether it is specific to that configuration?
Not specific to configuration

Other information

No response

@lindexi
Copy link
Member

lindexi commented Feb 25, 2025

Reference: #9980

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants