Skip to content

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

Description

@adegeo

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

Activity

  1. added
    Investigate
    on Nov 16, 2024
  2. lindexi commented on Nov 16, 2024

    @lindexi
    Member

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

  3. h3xds1nz commented on Nov 16, 2024

    @h3xds1nz
    Member

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

    @lindexi I for one think that's wrong, because this means that simply migrating your existing WPF app, you will have to do a full sweep for the GUI and add the alignment properties (sure, there's padding, font size, etc. but this is an additional step). That essentially "breaks" everyone's GUI after opting-in. I've seen it yesterday in the XAML and when testing the access keys, before this issue got posted and well, made me sad.

    Fun fact is though, you can't realistically fix this now this has been shipped.

    • Fixing it in a servicing release means you adjust the default behaviour on the fly, that's unacceptable.
    • Fixing it in next major release, oh well, let's have fun resetting alignment once again for developers that went through the migration — then again, given the amount of missing controls, styles, and functionality, and theme marked as experimental, I'd hope people will accept the theme only for evaluation and it can be adjusted to behave same as rest of the WPF themes in .NET 10.
  4. miloush commented on Nov 16, 2024

    @miloush
    Contributor

    Any of the theme stuff can certainly be fixed, it's all experimental. No one should be using it in production.

  5. lindexi commented on Nov 17, 2024

    @lindexi
    Member

    That essentially "breaks" everyone's GUI after opting-in.

    @h3xds1nz Yeah, I think you have a very convincing case.

    And I add the PR here #10082

    And maybe we need to review the layout of all other controls

  6. added this to the milestone on Feb 20, 2025
  7. modified the milestones: , 10.0.0 on Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🚧 work in progressInvestigateUI breaking wrt Aero2Win 11 Theming

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions