コード例 #1
0
 internal void InvokeProcessSort(KeyModifiers keyModifiers)
 {
     Debug.Assert(OwningGrid != null);
     if (OwningGrid.WaitForLostFocus(() => InvokeProcessSort(keyModifiers)))
     {
         return;
     }
     if (OwningGrid.CommitEdit(DataGridEditingUnit.Row, exitEditingMode: true))
     {
         Avalonia.Threading.Dispatcher.UIThread.Post(() => ProcessSort(keyModifiers));
     }
 }
コード例 #2
0
        public void Clear()
        {
            if (OwningGrid.SelectionMode == DataGridSelectionMode.Single)
            {
                throw DataGridError.DataGridSelectedItemsCollection.CannotChangeSelectedItemsCollectionInSingleMode();
            }

            if (_selectedSlotsTable.RangeCount > 0)
            {
                // Clearing the selection does not reset the potential current cell.
                if (!OwningGrid.CommitEdit(DataGridEditingUnit.Row, true /*exitEditing*/))
                {
                    // Edited value couldn't be committed or aborted
                    return;
                }
                OwningGrid.ClearRowSelection(true /*resetAnchorSlot*/);
            }
        }
コード例 #3
0
        public void RemoveAt(int index)
        {
            if (OwningGrid.SelectionMode == DataGridSelectionMode.Single)
            {
                throw DataGridError.DataGridSelectedItemsCollection.CannotChangeSelectedItemsCollectionInSingleMode();
            }

            if (index < 0 || index >= _selectedSlotsTable.IndexCount)
            {
                throw DataGridError.DataGrid.ValueMustBeBetween("index", "Index", 0, true, _selectedSlotsTable.IndexCount, false);
            }
            int rowIndex = _selectedSlotsTable.GetNthIndex(index);

            Debug.Assert(rowIndex > -1);

            if (rowIndex == OwningGrid.CurrentSlot &&
                !OwningGrid.CommitEdit(DataGridEditingUnit.Row, true /*exitEditing*/))
            {
                // Edited value couldn't be committed or aborted
                return;
            }

            OwningGrid.SetRowSelection(rowIndex, false /*isSelected*/, false /*setAnchorSlot*/);
        }
コード例 #4
0
        public void Remove(object dataItem)
        {
            if (OwningGrid.SelectionMode == DataGridSelectionMode.Single)
            {
                throw DataGridError.DataGridSelectedItemsCollection.CannotChangeSelectedItemsCollectionInSingleMode();
            }

            int itemIndex = OwningGrid.DataConnection.IndexOf(dataItem);

            if (itemIndex == -1)
            {
                return;
            }
            Debug.Assert(itemIndex >= 0);

            if (itemIndex == OwningGrid.CurrentSlot &&
                !OwningGrid.CommitEdit(DataGridEditingUnit.Row, true /*exitEditing*/))
            {
                // Edited value couldn't be committed or aborted
                return;
            }

            OwningGrid.SetRowSelection(itemIndex, false /*isSelected*/, false /*setAnchorSlot*/);
        }