Exemple #1
0
        private static IEnumerable <object> GetSelectedItems(DataGrid owningGrid, IndexToValueTable <bool> selectedItemsTable)
        {
            Debug.Assert(owningGrid != null);
            Debug.Assert(owningGrid.DataConnection != null);
            Debug.Assert(selectedItemsTable != null);

            DataGridDataConnection dataConnection = owningGrid.DataConnection;

            foreach (int rowIndex in selectedItemsTable.GetIndexes())
            {
                Debug.Assert(rowIndex > -1);
                yield return(dataConnection.GetDataItem(rowIndex));
            }
        }
        public DataGrid()
        {
            TabNavigation = KeyboardNavigationMode.Once;
            KeyDown += DataGrid_KeyDown;
            KeyUp += DataGrid_KeyUp;
            GotFocus += DataGrid_GotFocus;
            LostFocus += DataGrid_LostFocus;
            IsEnabledChanged += DataGrid_IsEnabledChanged;

            _loadedRows = new List<DataGridRow>();
            _selectedItems = new DataGridSelectedItemsCollection(this);
            _rowGroupHeaderStyles = new ObservableCollection<Style>();
            _rowGroupHeaderStyles.CollectionChanged += RowGroupHeaderStyles_CollectionChanged;
            _rowGroupHeaderStylesOld = new List<Style>();
            RowGroupHeadersTable = new IndexToValueTable<DataGridRowGroupInfo>();
            _validationResults = new List<ValidationResult>();

            DisplayData = new DataGridDisplayData(this);
            ColumnsInternal = CreateColumnsInstance();

            RowHeightEstimate = DATAGRID_defaultRowHeight;
            RowDetailsHeightEstimate = 0;
            _rowHeaderDesiredWidth = 0;

            DataConnection = new DataGridDataConnection(this);
            _showDetailsTable = new IndexToValueTable<Visibility>();
            _collapsedSlotsTable = new IndexToValueTable<Visibility>();

            AnchorSlot = -1;
            _lastEstimatedRow = -1;
            _editingColumnIndex = -1;
            _mouseOverRowIndex = null;
            CurrentCellCoordinates = new DataGridCellCoordinates(-1, -1);

            RowGroupHeaderHeightEstimate = DATAGRID_defaultRowHeight;

            DefaultStyleKey = typeof(DataGrid);
        }