Exemplo n.º 1
0
        public string GetDisplayTextFromGroup(object cell)
        {
            int groupIndex = TemplatedItems.GetGlobalIndexOfGroup(cell);

            if (groupIndex == -1)
            {
                return(cell.ToString());
            }

            var group = TemplatedItems.GetGroup(groupIndex);

            string displayBinding = null;

            if (GroupDisplayBinding != null)
            {
                displayBinding = group.Name;
            }

            if (GroupShortNameBinding != null)
            {
                displayBinding = group.ShortName;
            }

            // TODO: what if they set both? should it default to the ShortName, like it will here?
            // ShortNames binding did not appear to be functional before.
            return(displayBinding);
        }
Exemplo n.º 2
0
        public void NotifyRowTapped(int groupIndex, int inGroupIndex, Cell cell = null)
        {
            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));
            }

            cell?.OnTapped();

            ItemTapped?.Invoke(this, new ItemTappedEventArgs(ItemsSource.Cast <object>().ElementAt(groupIndex), cell?.BindingContext));
        }
Exemplo n.º 3
0
        internal void NotifyRowTapped(int groupIndex, int inGroupIndex, Cell cell = null)
        {
            var group = TemplatedItems.GetGroup(groupIndex);

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

            _previousRowSelected   = inGroupIndex;
            _previousGroupSelected = groupIndex;
            if (cell == null)
            {
                cell = group[inGroupIndex];
            }

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

            cell.OnTapped();

            ItemTapped?.Invoke(this, new ItemTappedEventArgs(ItemsSource.Cast <object>().ElementAt(groupIndex), cell.BindingContext));
        }
Exemplo n.º 4
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 >= 0 && group.Count > inGroupIndex)
            {
                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)));
        }