Reputation: 1025
I have a list view, with an itemtemplate, datatemplate, viewcell etc. In there I have a bunch of controls binding to the item properties. That all works great, but I do not seem to be able to reference another element on the same page within it, for example,
{Binding Path=MyProperty, Source={Reference AnotherElement}}
Even though I have another element on the same page called 'AnotherElement' that exposes 'MyProperty' and this exact binding works in other areas on the same page, I cannot get any bindings to refer to another element from within the listview itemtemplate.
Any ideas what I'm doing wrong?
Upvotes: 0
Views: 1092
Reputation: 16459
Since you are in a listview item template the Xamarin Forms ListView needs a binding context to map the binding with by that i mean it needs the reference of the Source of its binding context you can provide that using the ListViews x:Name
property
Give your list view a name:
<ListView x:Name="myList"...>
Then use its binding context as Source
Path=BindingContext.MyProperty, Source={x:Reference myList}}"/>
Upvotes: 1