Skip to content

Commit

Permalink
Fix selection logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Redth committed Jul 27, 2023
1 parent 7b4889b commit 186473b
Showing 2 changed files with 6 additions and 11 deletions.
5 changes: 0 additions & 5 deletions Sample/VirtualListViewSample/ObservableCollectionPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -17,15 +17,11 @@ public ObservableCollectionPage()
}

vlv.Adapter = Adapter;

//vlv.SetBinding(VirtualListView.SelectedItemsProperty, new Binding("SelectedItems", BindingMode.TwoWay, source: this));
}

public ObservableCollectionAdapter<string> Adapter { get; set; }
public ObservableCollection<string> Items = new();

//public ItemPosition[] SelectedItems = Array.Empty<ItemPosition>();

protected override void OnAppearing()
{
base.OnAppearing();
@@ -61,6 +57,5 @@ private void vlv_SelectedItemsChanged(object sender, SelectedItemsChangedEventAr

Items.Remove(item);
}

}
}
12 changes: 6 additions & 6 deletions Sample/VirtualListViewSample/SectionedAdapterPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -38,13 +38,13 @@ private void Button_Clicked(object sender, EventArgs e)

private void vlv_SelectedItemsChanged(object sender, SelectedItemsChangedEventArgs e)
{
var item = e.NewSelection?.FirstOrDefault();

if (item != null)
if (e.NewSelection.Any())
{
Adapter.RemoveItem(item.Value.SectionIndex, item.Value.ItemIndex);
}
var item = e.NewSelection.First();

(sender as VirtualListView).SelectedItems = null;
Adapter.RemoveItem(item.SectionIndex, item.ItemIndex);
vlv.ClearSelectedItems();
}

}
}

0 comments on commit 186473b

Please sign in to comment.