Reputation: 165
I have a custom ItemView that I am trying to implement and I want to raise event back to ListView that is a parent. How do I go about doing that?
For example my ItemView has. How do I get the ListView owner to invoke event?
public partial class MyItemView : ContentView, INotifyPropertyChanged
{
}
Upvotes: 0
Views: 69
Reputation: 599
You can get the ListView from the item of ListView by iterating View's parent till we get the ListView.
public partial class MyItemView : ContentView, INotifyPropertyChanged
{
ListView listView;
protected override void LayoutChildren(double x, double y, double width, double height)
{
base.LayoutChildren(x, y, width, height);
Element list = this;
while(list.GetType() != typeof(ListView))
{
list = list.Parent;
}
listView = list as ListView;
}
}
Upvotes: 1