Skip to content

Commit

Permalink
Fix for BindingContext in ListView Header or Footer
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Peppers committed Jun 17, 2016
1 parent 4fa3c8c commit d0170a4
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion Xamarin.Forms.Core/ListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -536,5 +536,36 @@ static bool ValidateHeaderFooterTemplate(BindableObject bindable, object value)
var template = (DataTemplate)value;
return template.CreateContent() is View;
}
}

protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();

//NOTE: BindingContext was not passing through ListView to its Header or Footer

var gotBindingContext = false;
object bc = null;

var header = Header as Element;
if (header != null)
{
bc = BindingContext;
gotBindingContext = true;

SetChildInheritedBindingContext(header, bc);
}

var footer = Footer as Element;
if (footer != null)
{
if (!gotBindingContext)
{
bc = BindingContext;
gotBindingContext = true;
}

SetChildInheritedBindingContext(footer, bc);
}
}
}
}

0 comments on commit d0170a4

Please sign in to comment.