microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.27k stars 674 forks source link

WinUI2.7 Rounded corners are removed form the Button when you set the Style to null #6156

Open sonnemaf opened 2 years ago

sonnemaf commented 2 years ago

Describe the bug

The rounded corners of a Button are removed when a Button has a Style (for example the AccentButtonStyle) and you remove it by setting the Style property to `null'.

Steps to reproduce the bug

Create a new UWP project and add Microsoft.UI.Xaml NuGet package.

Add the following code to the MainPage.xaml

    <StackPanel HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Spacing="12">
        <Button Click="Button1_Click"
                Content="Button 1" />
        <Button x:Name="button2"
                Content="Button 2"
                Style="{StaticResource AccentButtonStyle}" />
    </StackPanel>
public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();
    }

    private void Button1_Click(object sender, RoutedEventArgs e) {
        button2.Style = null;
    }
}

Run the app and click Button 1

Expected behavior

The Button 2 should have rounded corners

Screenshots

The app starts like this.

image

If you click Button 1 the rounded corners are removed from Button 2.

image

NuGet package version

Microsoft.UI.Xaml 2.7.0

Windows app type

Device form factor

Desktop

Windows version

No response

Additional context

No response

StephenLPeters commented 2 years ago

Very strange... the button does have the correct "DefaultButtonStyle" from winui2, you can tell from the bottom edge border being a bit darker, but the corner radius value lookup seems to have failed... @MikeHillberg or @jevansaks ring any bells?

lgBlog commented 2 years ago