Skip to content

Allow TextSearch.TextBinding on non-controls.#20884

Merged
MrJul merged 7 commits intomasterfrom
refactor/textsearch-avaloniaobject
Mar 16, 2026
Merged

Allow TextSearch.TextBinding on non-controls.#20884
MrJul merged 7 commits intomasterfrom
refactor/textsearch-avaloniaobject

Conversation

@grokys
Copy link
Member

@grokys grokys commented Mar 12, 2026

What does the pull request do?

Allows setting TextSearch.TextBinding on non-controls: in particular I would like to be able to set it on (tree) data grid columns. For example:

<TreeDataGrid>
  <TreeDataGridTemplateColumn TextSearch.TextBinding="{Binding Foo}">
    <DataTemplate>
      <TextBlock Text="{Binding Foo}"/>
    </DataTemplate>
  </TreeDataGridTemplateColumn>
</TreeDataGrid>

What is the current behavior?

The attached property is only intended to be applied to Interactive controls. Data grid columns are not interactive, but they do produce interactive elements.

What is the updated/expected behavior with this PR?

Text search bindings can be set on arbitrary elements.

Breaking changes

The GetTextBinding/SetTextBinding methods accept a different object type. This is a less specific type and so shouldn't be a source breaking change.

Allow setting `TextSearch.TextBinding` on non-controls: in particular I would like to be able to set it on (tree) data grid columns. For example:

```
<TreeDataGrid>
  <TreeDataGridTemplateColumn TextSearch.TextBinding="{Binding Foo}">
    <DataTemplate>
      <TextBlock Text="{Binding Foo}"/>
    </DataTemplate>
  </TreeDataGridTemplateColumn>
</TreeDataGrid>
```
@grokys grokys requested review from MrJul and Copilot March 12, 2026 22:54
@grokys grokys added needs-api-review The PR adds new public APIs that should be reviewed. wont-backport labels Mar 12, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Expands the TextSearch.TextBinding attached property so it can be set on non-Interactive objects (e.g., column definitions), enabling consumers to surface text-search metadata on non-control elements that still participate in generating interactive UI.

Changes:

  • Broaden TextSearch.TextBindingProperty registration target from Interactive to AvaloniaObject.
  • Update GetTextBinding/SetTextBinding APIs and XML docs to accept AvaloniaObject.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@MrJul
Copy link
Member

MrJul commented Mar 13, 2026

For consistency, I think the same change should be applied to TextSearch.Text.

@MrJul
Copy link
Member

MrJul commented Mar 13, 2026

/update-api

@github-actions
Copy link

/update-api failed. See logs.

@MrJul MrJul added api-approved The new public APIs have been approved. and removed needs-api-review The PR adds new public APIs that should be reviewed. labels Mar 13, 2026
@AvaloniaUI AvaloniaUI deleted a comment from github-actions bot Mar 13, 2026
@maxkatz6
Copy link
Member

/update-api

@github-actions
Copy link

/update-api failed. See logs.

@MrJul MrJul enabled auto-merge March 16, 2026 09:23
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0063459-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul added this pull request to the merge queue Mar 16, 2026
Merged via the queue into master with commit 38880ee Mar 16, 2026
11 checks passed
@MrJul MrJul deleted the refactor/textsearch-avaloniaobject branch March 16, 2026 11:54
@grokys
Copy link
Member Author

grokys commented Mar 17, 2026

For consistency, I think the same change should be applied to TextSearch.Text.

Yeah I wasn't sure about that. What would be the use-case?

@MrJul
Copy link
Member

MrJul commented Mar 17, 2026

Yeah I wasn't sure about that. What would be the use-case?

Sorry, I already made the changes.

Mostly for consistency: nothing prevents a user from putting objects derived from AvaloniaObject in a ListBox right now, and it would be a bit odd to have one property work and not the other, in my opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants