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

Binding properties of type Thickness in Resource crashes the app #10078

Open
HO-COOH opened this issue Oct 17, 2024 · 1 comment
Open

Binding properties of type Thickness in Resource crashes the app #10078

HO-COOH opened this issue Oct 17, 2024 · 1 comment
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners

Comments

@HO-COOH
Copy link

HO-COOH commented Oct 17, 2024

Describe the bug

Binding properties of type Thickness, like Margin and Padding in Resource will cause the app to crash. The crash happens before the getter of the binding is even called.

I thought it might be unsupported, but using the same way to bind Color does work. So there might be an issue here.

Steps to reproduce the bug

  1. Create a new WinUI3 C++ packaged project
  2. In MainWindow.xaml, use this xaml
<StackPanel Orientation="Horizontal">
        <StackPanel.Resources>
            <Style
                x:Key="MyButtonStyle"
                BasedOn="{StaticResource AccentButtonStyle}"
                TargetType="Button">
 
                <Setter Property="Margin" Value="{x:Bind MyPadding, Mode=OneWay}" />
            </Style>
        </StackPanel.Resources>
        <Button Style="{StaticResource MyButtonStyle}">Click Me</Button>
    </StackPanel>
  1. In code-behind, return random values for the binding
winrt::Microsoft::UI::Xaml::Thickness MyPadding() { return {1,2,3,4}; }

Expected behavior

No response

Screenshots

Image

NuGet package version

WinUI 3 - Windows App SDK 1.6.1: 1.6.240923002

Windows version

Windows 11 (22H2): Build 22621

Additional context

Image
Repro

@HO-COOH HO-COOH added the bug Something isn't working label Oct 17, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Oct 17, 2024
@kmgallahan
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners
Projects
None yet
Development

No branches or pull requests

2 participants