private void OnItemClick(object sender, ItemClickEventArgs args) { ItemClick?.Invoke(this, new Windows.UI.Xaml.Controls.ItemClickEventArgs { ClickedItem = BindableAdapter.GetRawItem(args.Position) }); HandleItemSelection(args); }
private void HandleItemSelection(ItemClickEventArgs args) { if (SelectionMode != ListViewSelectionMode.None) { var newSelection = BindableAdapter.GetRawItem(args.Position); switch (SelectionMode) { case ListViewSelectionMode.Single: var selectedItem = BindableAdapter.SelectedItems.FirstOrDefault(); // Unselect the current item only if a new selection is made or // the option to unselect the current item is activated. if (selectedItem != null && (selectedItem != newSelection || UnselectOnClick)) { BindableAdapter.SetItemSelection(selectedItem, null, false); } if (selectedItem != newSelection) { BindableAdapter.SetItemSelection( newSelection, (args.View as ItemContainerHolder)?.Child as SelectorItem, true ); } SelectedItem = newSelection; break; case ListViewSelectionMode.Multiple: BindableAdapter.SetItemSelection( BindableAdapter.GetRawItem(args.Position), args.View as SelectorItem, !BindableAdapter.SelectedItems.Contains(newSelection) ); break; } SelectedItems = BindableAdapter.SelectedItems.ToArray(); } }
private void ExecuteCommandOnItem(ICommand command, int position) { if (command == null) { return; } var item = BindableAdapter.GetRawItem(position); if (item == null) { return; } if (!command.CanExecute(item)) { return; } command.Execute(item); }