Binding resolution for TemplateBinding fails when value provided by upper Binding #33984
Unanswered
BigBallard
asked this question in
Q&A
Replies: 2 comments 6 replies
-
|
I would name your property Collapser.LabelText instead of Collapser.Label. Also, I would implement it using C#, no need for XAML: using CommunityToolkit.Maui;
using CommunityToolkit.Maui.Markup;
public partial class Collapser : ContentView
{
[BindableProperty]
public partial string LabelText { get; set; } = string.Empty;
public Collapser()
{
ControlTemplate = new ControlTemplate(
() => new VerticalStackLayout
{
new HorizontalStackLayout { new Label().Bind(Label.TextProperty, (Collapser c) => c.LabelText, source: this) },
new ContentPresenter()
});
}
} |
Beta Was this translation helpful? Give feedback.
3 replies
-
|
Your stack trace references code you haven’t provided, and without that missing context the issue can’t be reproduced. Using only the code you shared, I was able to build an application that runs without crashing, so the problem is likely in the parts you haven’t included. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a custom control
Collapserthat has aTemplateBindingof Label. I am attempting to useCollapserin aDataTemplateforCollectionView. I am getting a linq error when the parent view attempts to resolve everything. When I pass a literal to the Label instead of a binding, it works. I don't know enough about XAML to make any assumptions as to what is happening. The stacktrace is less than helpful for me.Collection xaml
Collapser xaml
ItemCategory cs
Exception stack
Beta Was this translation helpful? Give feedback.
All reactions