Пример #1
0
        public void NotifyRowTapped(int groupIndex, int inGroupIndex, Cell cell, bool isContextMenuRequested)
        {
            var group = TemplatedItems.GetGroup(groupIndex);

            bool changed = _previousGroupSelected != groupIndex || _previousRowSelected != inGroupIndex;

            _previousRowSelected   = inGroupIndex;
            _previousGroupSelected = groupIndex;

            // A11y: Keyboards and screen readers can deselect items, allowing -1 to be possible
            if (cell == null && inGroupIndex != -1)
            {
                cell = group[inGroupIndex];
            }

            // Set SelectedItem before any events so we don't override any changes they may have made.
            if (SelectionMode != ListViewSelectionMode.None)
            {
                SetValueCore(SelectedItemProperty, cell?.BindingContext, SetValueFlags.ClearOneWayBindings | SetValueFlags.ClearDynamicResource | (changed ? SetValueFlags.RaiseOnEqual : 0));
            }

            if (isContextMenuRequested || cell == null)
            {
                return;
            }

            cell.OnTapped();

            var    itemSource  = ItemsSource?.Cast <object>().ToList();
            object tappedGroup = null;

            if (itemSource?.Count > groupIndex)
            {
                tappedGroup = itemSource.ElementAt(groupIndex);
            }

            ItemTapped?.Invoke(this,
                               new ItemTappedEventArgs(tappedGroup, cell.BindingContext,
                                                       TemplatedItems.GetGlobalIndexOfItem(cell?.BindingContext)));
        }
Пример #2
0
 public void SendCellDisappearing(Cell cell)
 => ItemDisappearing?.Invoke(this, new ItemVisibilityEventArgs(cell.BindingContext, TemplatedItems.GetGlobalIndexOfItem(cell?.BindingContext)));