I am creating a custom DataTemplate
that trigger an event in it's parent listview. Here is one trigger:
public void OnItemActivated()
{
ParentView.OnItemActivated(this);
}
'Element.ParentView' is obsolete: 'ParentView is obsolete as of version 2.1.0. Please use Parent instead. - Says Xamarin
In the above image you can see that Parent
and ParentView
are diferents and ParentView
return the object
I need. I would try to use Parent.Parent
which work in this case ... Will that always work ? Will that hierarchical structure be always the same ?
So I need the best way to get the listview
that own the "active" item
Perhaps someone could advice me if the listview
should be listening to his children or should wait for them to talk to him
I finally understood why ParentView
is obsolete. The Xamarin page "Document Structure" is not just made by Views, but Elements.
As a parent of a view may not be a view, ParentView
become useless.
My Solution
I use (this.Parent as Xamarin.Forms.View)
to get my ParentView
, my Parent as View :)
Note
As I said Parent
is an Element
which sometime is View
. So my solution will crash when the Parent is not a View (Why ParentView
is Obsolete)