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

Fix TemplateBinding in custom IControlTemplate implementations #17427

Conversation

MrJul
Copy link
Member

@MrJul MrJul commented Nov 4, 2024

What does the pull request do?

This PR allows TemplateBinding to work inside custom IControlTemplate implementations.
A unit test has been added.

What is the current behavior?

The XAML compiler fails with AVLN3000: Unable to find the ControlTemplate scope for AvaloniaProperty lookup

What is the updated/expected behavior with this PR?

TemplateBinding works inside any implementation of IControlTemplate.

@MrJul MrJul added bug area-xaml customer-priority Issue reported by a customer with a support agreement. backport-candidate-11.2.x Consider this PR for backporting to 11.2 branch labels Nov 4, 2024
@MrJul MrJul requested a review from maxkatz6 November 4, 2024 16:47
Copy link
Member

@maxkatz6 maxkatz6 left a comment

Choose a reason for hiding this comment

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

Makes sense to me.
Has anybody reported this issue? I wonder how they use custom control templates.

@avaloniaui-bot
Copy link

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

@TomEdwardsEnscape
Copy link
Contributor

TomEdwardsEnscape commented Nov 5, 2024

Has anybody reported this issue? I wonder how they use custom control templates.

I reported it via the customer support system. We have multiple custom template types (data, control, itemspanel...) which capture and restore a dependency injection context. This allows controls generated after the window opens (e.g. virtualised list items) to find the correct dependencies.

@MrJul MrJul enabled auto-merge November 5, 2024 09:15
@avaloniaui-bot
Copy link

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

@maxkatz6 maxkatz6 disabled auto-merge November 5, 2024 22:33
@maxkatz6 maxkatz6 merged commit 8f7686f into AvaloniaUI:master Nov 5, 2024
2 checks passed
maxkatz6 added a commit that referenced this pull request Nov 14, 2024
* Add failing test for TemplateBinding inside custom control template

* Fix TemplateBinding XAML compilation error for custom IControlTemplate

---------

Co-authored-by: Max Katz <maxkatz6@outlook.com>
@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
@MrJul MrJul deleted the fix/templatebinding-in-custom-controltemplate branch December 21, 2024 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-xaml backported-11.2.x bug customer-priority Issue reported by a customer with a support agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants