microsoft / microsoft/microsoft-ui-xaml

Binding to a control name does not work in C++

Open
#10,629 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-Binding bug team-Core
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

Binding a `TextBlock.Text` property to a `x:Name` named control works in C#, but not in C++.

### Steps to reproduce the bug

1. Create a new winui3 project, under `MainWindow.xaml`
2. Use this xaml
```xml






```

In C# project, the text is correctly shown, not in C++

![Image](https://github.com/user-attachments/assets/03cb455d-700d-4a0a-a439-1762eb229962)

### Expected behavior

_No response_

### Screenshots

_No response_

### NuGet package version

WinUI 3 - Windows App SDK 1.7.3: 1.7.250606001

### Windows version

Windows 11 (24H2): Build 26100

### Additional context

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the binding in MainWindow.xaml using a WinUI 3 C++ project, then compare it with the equivalent C# project. Investigate the binding path from ElementName=MyButton to the TextBlock and verify that the displayed value is MyButton.Name when the issue is fixed.

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.