Skip to content

Commit

Permalink
Use the bindingcontext of listview if item data is null
Browse files Browse the repository at this point in the history
Use the binding context of the listview parent control in cases where recycling a view's data is null.  This is likely going to be the global header/footer and possibly section header/footer too
  • Loading branch information
Redth committed Aug 12, 2023
1 parent 02547a2 commit 0e1f96c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion VirtualListView/Controls/VirtualListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,12 @@ public void RecycleView(PositionInfo position, object data, IView view)
{
if (view is View controlsView)
{
controlsView.SetValue(View.BindingContextProperty, data);
// Use the listview's binding context if
// there's no data
// this may happen for global header/footer for instance
controlsView.SetValue(
View.BindingContextProperty,
data ?? this.BindingContext);
}
}

Expand Down

0 comments on commit 0e1f96c

Please sign in to comment.