microsoft / microsoft/microsoft-ui-xaml

Binding properties of type `Thickness` in `Resource` crashes the app

Open
#10,078 1 comment 0 reactions 0 assignees View on GitHub
area-Binding bug team-Markup
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### 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
```xml




<Setter Property="Margin" Value="{x:Bind MyPadding, Mode=OneWay}" />


Click Me

```
3. In code-behind, return random values for the binding
```cpp
winrt::Microsoft::UI::Xaml::Thickness MyPadding() { return {1,2,3,4}; }
```

### Expected behavior

_No response_

### Screenshots

![Image](https://github.com/user-attachments/assets/e8d86aba-ff35-401f-9cda-37bb5c7be5de)

### NuGet package version

WinUI 3 - Windows App SDK 1.6.1: 1.6.240923002

### Windows version

Windows 11 (22H2): Build 22621

### Additional context

![Image](https://github.com/user-attachments/assets/ba38d167-cff5-49c8-9da7-593c492f9cd0)
[Repro](https://github.com/HO-COOH/WinUI-Bug/tree/main/20-BindingThicknessInResourceCrash)

Contributor guide

Open the contributing guide

Research direction

Start by running the repro in 20-BindingThicknessInResourceCrash and inspect MainWindow.xaml together with its code-behind. Confirm whether the crash occurs when the Thickness-valued x:Bind is used in the Resource style, compare it with the working Color binding, and document the result as the completion criterion.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.