dotnet / dotnet/wpf

LabeledBy property seems not be set on controls targeted by label

Open
#9,185 0 comments 0 reactions 0 assignees View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

I have such a xaml snippet:
```
Miesiąc

```

The documentation says setting this `Target` property on label should also update automation properties so that my screenreader could see the combobox being labeled, however this seems not to work as intended, as my screenreader doesn't see combobox being labeled.
However, manually setting `AutomationProperties.LabeledBy` or `AutomationProperties.Name` on combobox does work, and I also see in the Label.cs code that there is some code that updates the labeledby, but I can't check it's validity as I don't really know wpf enough to debug.
I have however checked that the `Target` property is being set correctly via data binding expression and it has a value.

### Reproduction Steps

* Create a wpf project with the following main window xaml snippet:
```


Miesiąc

Rok

Liczba dni

```

Note each focusabkle control should have a label here.
* Run the program and run narrator, try tabbing through controls in the window.

### Expected behavior

Screenreader should read the control label along with it's value, for example (it's in polish): "Miesiąc combo box", confirming that the LabeledBy is set on label

### Actual behavior

Screenreader just reads it's a combobox, which confirms LabeledBy is not set.

### Regression?

Probably a long standing wpf bug or common misconfiguration.

### Known Workarounds

One can manually set attached properties like `AutomationProperties.LabeledBy` or even `AutomationProperties.Name`, both seem to work.

### Impact

The bug impacts all accewssibility/screenreader users of wpf applications, if my information is correct.

### Configuration

Using .NET 8.0.6, currently creating the project with vscode as I don't have visual studio, however that shouldn't matter.

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.