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

Setting ThemeMode on a window causes a button to be positioned differently #10077

Open
adegeo opened this issue Nov 15, 2024 · 1 comment
Open
Labels
Investigate Requires further investigation by the WPF team. Win 11 Theming

Comments

@adegeo
Copy link
Contributor

adegeo commented Nov 15, 2024

Description

Setting ThemeMode on a window causes a button to be completely repositioned.

Reproduction Steps

  1. Brand new WPF project.
  2. Add a button to the grid and set the width/height to something small.
  3. Set the ThemeMode property on the window to anything other than None.
<Window x:Class="Names.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"
        xmlns:local="clr-namespace:Names"
        mc:Ignorable="d"
        Title="MainWindow" Height="300" Width="400" ThemeMode="System">
    <Grid>
        <Button Width="200" Height="30" />
    </Grid>
</Window>

Before ThemeMode is set:

Image

After ThemeMode is set:

Image

Expected behavior

Don't alter the layout.

Actual behavior

Layout is altered.

Regression?

No response

Known Workarounds

No response

Impact

No response

Configuration

  • Visual Studio 2022 17.12 GA
  • .NET 9 GA

Other information

No response

@lindexi lindexi added Investigate Requires further investigation by the WPF team. Win 11 Theming labels Nov 16, 2024
@lindexi
Copy link
Member

lindexi commented Nov 16, 2024

@adegeo

The style define is in \src\Themes\PresentationFramework.Fluent\Styles\Button.xaml

<Setter Property="HorizontalAlignment" Value="Left" />

See #8870

And in WinUI, the default button style is also left-aligned, so I think this style is appropriate here. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Investigate Requires further investigation by the WPF team. Win 11 Theming
Projects
None yet
Development

No branches or pull requests

2 participants