Repository navigation
Fix null Content.Name binding errors - #5503
Open
Sébastien Duquette (sduquette-devolutions) wants to merge 1 commit into
Open
Sébastien Duquette (sduquette-devolutions) wants to merge 1 commit into
Sébastien Duquette (sduquette-devolutions) wants to merge 1 commit into
Conversation
The message "An error occurred binding 'Name' to 'Content.Name' at 'Content': 'Value is null.'" appeared multiple times in the console when starting the app. The cause was a global style in `Styles.Common.axaml`. It copies the automation name (the accessible name used by screen readers) from each `DataGridCell`'s content. The DataGrid reuses cells as you scroll, so the content is briefly null, and the old binding path then logged "Value is null." I replaced it with a binding that tolerates a null content. It uses a new converter, `Converters/AutomationNameOfContentConverter.cs`. The cell's accessible name is now read once from the content instead of tracking later changes to it. The templates set it statically, so that shouldn't matter in practice.
Sébastien Duquette (sduquette-devolutions)
requested review from
Gabriel Dufresne (GabrielDuf)
and
a balanced review from Copilot
October 10, 2026 13:23
Copilot started reviewing on behalf of
Sébastien Duquette (sduquette-devolutions)
October 10, 2026 13:24
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new binding can retain stale names and misses asynchronous automation-name updates.
2 open findings
What changed in this PR
Updates DataGrid automation-name binding to tolerate recycled cells with null content.
Changes:
- Adds an automation-name converter.
- Uses it in the global
DataGridCellstyle.
| File | Description |
|---|---|
AutomationNameOfContentConverter.cs |
Resolves automation names from cell content. |
Styles.Common.axaml |
Applies the converter globally to DataGrid cells. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| <Style Selector="DataGridCell"> | ||
| <Setter Property="automation:AutomationProperties.Name" Value="{Binding $self.((Control)Content).(automation:AutomationProperties.Name)}"/> | ||
| <Setter Property="automation:AutomationProperties.Name" Value="{Binding $self.Content, Converter={x:Static conv:AutomationNameOfContentConverter.Instance}}"/> |
| public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
| => value is Control control | ||
| ? AutomationProperties.GetName(control) | ||
| : BindingOperations.DoNothing; |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The message "An error occurred binding 'Name' to 'Content.Name' at 'Content': 'Value is null.'" appeared multiple times in the console when starting the app. The cause was a global style in
Styles.Common.axaml. It copies the automation name (the accessible name used by screen readers) from eachDataGridCell's content. The DataGrid reuses cells as you scroll, so the content is briefly null, and the old binding path then logged "Value is null."I replaced it with a binding that tolerates a null content. It uses a new converter,
Converters/AutomationNameOfContentConverter.cs. The cell's accessible name is now read once from the content instead of tracking later changes to it. The templates set it statically, so that shouldn't matter in practice.