internal Visibility GetRowDetailsVisibility(int rowIndex, DataGridRowDetailsVisibilityMode gridLevelRowDetailsVisibility)
 {
     Debug.Assert(rowIndex != -1);
     if (_showDetailsTable.Contains(rowIndex))
     {
         // The user explicity set DetailsVisibility on a row so we should respect that
         return _showDetailsTable.GetValueAt(rowIndex);
     }
     else
     {
         if (gridLevelRowDetailsVisibility == DataGridRowDetailsVisibilityMode.Visible ||
             (gridLevelRowDetailsVisibility == DataGridRowDetailsVisibilityMode.VisibleWhenSelected &&
              _selectedItems.ContainsSlot(SlotFromRowIndex(rowIndex))))
         {
             return Visibility.Visible;
         }
         else
         {
             return Visibility.Collapsed;
         }
     }
 }
        private void UpdateRowDetailsVisibilityMode(DataGridRowDetailsVisibilityMode newDetailsMode)
        {
            int itemCount = this.DataConnection.Count;
            if (this._rowsPresenter != null && itemCount > 0)
            {
                Visibility newDetailsVisibility = Visibility.Collapsed;
                switch (newDetailsMode)
                {
                    case DataGridRowDetailsVisibilityMode.Visible:
                        newDetailsVisibility = Visibility.Visible;
                        this._showDetailsTable.AddValues(0, itemCount, Visibility.Visible);
                        break;
                    case DataGridRowDetailsVisibilityMode.Collapsed:
                        newDetailsVisibility = Visibility.Collapsed;
                        this._showDetailsTable.AddValues(0, itemCount, Visibility.Collapsed);
                        break;
                    case DataGridRowDetailsVisibilityMode.VisibleWhenSelected:
                        this._showDetailsTable.Clear();
                        break;
                }

                bool updated = false;
                foreach (DataGridRow row in this.GetAllRows())
                {
                    if (row.Visibility == Visibility.Visible)
                    {
                        if (newDetailsMode == DataGridRowDetailsVisibilityMode.VisibleWhenSelected)
                        {
                            // For VisibleWhenSelected, we need to calculate the value for each individual row
                            newDetailsVisibility = this._selectedItems.ContainsSlot(row.Slot) ? Visibility.Visible : Visibility.Collapsed;
                        }
                        if (row.DetailsVisibility != newDetailsVisibility)
                        {
                            updated = true;
                            row.SetDetailsVisibilityInternal(newDetailsVisibility, true /* raiseNotification */, false /* animate */);
                        }
                    }
                }
                if (updated)
                {
                    UpdateDisplayedRows(this.DisplayData.FirstScrollingSlot, this.CellsHeight);
                    InvalidateRowsMeasure(false /*invalidateIndividualElements*/);
                }
            }
        }
Exemplo n.º 3
0
 public static T RowDetailsVisibilityMode <T>(this T target, DataGridRowDetailsVisibilityMode value) where T : DataGrid
 {
     target.RowDetailsVisibilityMode = value;
     return(target);
 }