Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable TemplateBinding inside ItemsPanelTemplate #17483

Merged

Conversation

MrJul
Copy link
Member

@MrJul MrJul commented Nov 12, 2024

What does the pull request do?

This PR allows TemplateBinding to work inside ItemsPanelTemplate, or any specially annotated template type.

What is the current behavior?

In avalonia 11.2, when trying to use TemplateBinding inside an ItemsPanelTemplate, this fails with AVLN3000: Unable to find the ControlTemplate scope for AvaloniaProperty lookup.

What is the updated/expected behavior with this PR?

TemplateBinding works in ItemsPanelTemplate. The target type is found on the parent Style or control.

How was the solution implemented (if it's not obvious)?

A new attribute [ControlTemplateScope] has been added. Any template type annotated with this attribute is considered to be in control template scope: TemplateBinding works, binding priorities are set to Template, etc. (same behavior as a standard ControlTemplate)

This attribute has been applied to IControlTemplate (effectively superseding #17427) and ItemsPanelTemplate.

New unit tests have been added for ItemsPanelTemplate containing TemplateBindings.

@MrJul MrJul added area-xaml customer-priority Issue reported by a customer with a support agreement. area-bindings backport-candidate-11.2.x Consider this PR for backporting to 11.2 branch labels Nov 12, 2024
@MrJul MrJul requested a review from maxkatz6 November 12, 2024 16:50
@MrJul MrJul added the feature label Nov 12, 2024
@avaloniaui-bot
Copy link

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

@punker76
Copy link
Contributor

@MrJul Nice! 👍

@maxkatz6 maxkatz6 merged commit 8ec3b6b into AvaloniaUI:master Nov 14, 2024
11 checks passed
@maxkatz6 maxkatz6 added backported-11.2.x and removed backport-candidate-11.2.x Consider this PR for backporting to 11.2 branch labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-bindings area-xaml backported-11.2.x customer-priority Issue reported by a customer with a support agreement. feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants