private static void OnHeaderStylePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DataGridRowGroupHeader groupHeader = d as DataGridRowGroupHeader;

            if (groupHeader._headerElement != null)
            {
                groupHeader._headerElement.EnsureStyle(e.OldValue as Style);
            }
        }
 internal DataGridRowGroupHeader GetUsedGroupHeader()
 {
     if (_recyclableGroupHeaders.Count > 0)
     {
         return(_recyclableGroupHeaders.Pop());
     }
     else if (_fullyRecycledGroupHeaders.Count > 0)
     {
         // For fully recycled rows, we need to set the Visibility back to Visible
         DataGridRowGroupHeader groupHeader = _fullyRecycledGroupHeaders.Pop();
         groupHeader.Visibility = Visibility.Visible;
         return(groupHeader);
     }
     return(null);
 }
 internal void PrintDisplay()
 {
     foreach (UIElement element in this.GetScrollingElements())
     {
         DataGridRow row = element as DataGridRow;
         if (row != null)
         {
             Debug.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Slot: {0} Row: {1} ", row.Slot, row.Index));
         }
         else
         {
             DataGridRowGroupHeader groupHeader = element as DataGridRowGroupHeader;
             if (groupHeader != null)
             {
                 Debug.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Slot: {0} GroupHeader: {1}", groupHeader.RowGroupInfo.Slot, groupHeader.RowGroupInfo.CollectionViewGroup.Name));
             }
         }
     }
 }
 internal void FullyRecycleElements()
 {
     // Fully recycle Recycleable rows and transfer them to Recycled rows
     while (_recyclableRows.Count > 0)
     {
         DataGridRow row = _recyclableRows.Pop();
         Debug.Assert(row != null);
         row.Visibility = Visibility.Collapsed;
         Debug.Assert(!_fullyRecycledRows.Contains(row));
         _fullyRecycledRows.Push(row);
     }
     // Fully recycle Recycleable GroupHeaders and transfer them to Recycled GroupHeaders
     while (_recyclableGroupHeaders.Count > 0)
     {
         DataGridRowGroupHeader groupHeader = _recyclableGroupHeaders.Pop();
         Debug.Assert(groupHeader != null);
         groupHeader.Visibility = Visibility.Collapsed;
         Debug.Assert(!_fullyRecycledGroupHeaders.Contains(groupHeader));
         _fullyRecycledGroupHeaders.Push(groupHeader);
     }
 }
 internal void ClearElements(bool recycle)
 {
     ResetSlotIndexes();
     if (recycle)
     {
         foreach (UIElement element in _scrollingElements)
         {
             DataGridRow row = element as DataGridRow;
             if (row != null)
             {
                 if (row.IsRecyclable)
                 {
                     AddRecylableRow(row);
                 }
                 else
                 {
                     row.Clip = new RectangleGeometry();
                 }
             }
             else
             {
                 DataGridRowGroupHeader groupHeader = element as DataGridRowGroupHeader;
                 if (groupHeader != null)
                 {
                     AddRecylableRowGroupHeader(groupHeader);
                 }
             }
         }
     }
     else
     {
         _recyclableRows.Clear();
         _fullyRecycledRows.Clear();
         _recyclableGroupHeaders.Clear();
         _fullyRecycledGroupHeaders.Clear();
     }
     _scrollingElements.Clear();
 }
        private static void OnSublevelIndentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DataGridRowGroupHeader groupHeader = d as DataGridRowGroupHeader;
            double newValue = (double)e.NewValue;

            // We don't need to revert to the old value if our input is bad because we never read this property value
            if (double.IsNaN(newValue))
            {
                throw DataGridError.DataGrid.ValueCannotBeSetToNAN("SublevelIndent");
            }
            else if (double.IsInfinity(newValue))
            {
                throw DataGridError.DataGrid.ValueCannotBeSetToInfinity("SublevelIndent");
            }
            else if (newValue < 0)
            {
                throw DataGridError.DataGrid.ValueMustBeGreaterThanOrEqualTo("value", "SublevelIndent", 0);
            }

            if (groupHeader.OwningGrid != null)
            {
                groupHeader.OwningGrid.OnSublevelIndentUpdated(groupHeader, newValue);
            }
        }
 internal void UpdateRowGroupHeaderPeerEventsSource(DataGridRowGroupHeader header)
 {
     object group = header.RowGroupInfo.CollectionViewGroup;
     DataGridRowGroupHeaderAutomationPeer peer = DataGridRowGroupHeaderAutomationPeer.FromElement(header) as DataGridRowGroupHeaderAutomationPeer;
     if (peer != null && group != null && _groupItemPeers.ContainsKey(group))
     {
         peer.EventsSource = _groupItemPeers[group];
     }
 }
 /// <summary>
 /// AutomationPeer for DataGridRowGroupHeader
 /// </summary>
 /// <param name="owner">DataGridRowGroupHeader</param>
 public DataGridRowGroupHeaderAutomationPeer(DataGridRowGroupHeader owner)
     : base(owner)
 {
 }
 /// <summary>
 /// Constructs a DataGridRowGroupHeaderEventArgs instance
 /// </summary>
 /// <param name="rowGroupHeader"></param>
 public DataGridRowGroupHeaderEventArgs(DataGridRowGroupHeader rowGroupHeader)
 {
     this.RowGroupHeader = rowGroupHeader;
 }
        internal void OnSublevelIndentUpdated(DataGridRowGroupHeader groupHeader, double newValue)
        {
            Debug.Assert(this.DataConnection.CollectionView != null);
            Debug.Assert(this.RowGroupSublevelIndents != null);

            int groupLevelCount = this.DataConnection.CollectionView.GroupDescriptions.Count;
            Debug.Assert(groupHeader.Level >= 0 && groupHeader.Level < groupLevelCount);

            double oldValue = this.RowGroupSublevelIndents[groupHeader.Level];
            if (groupHeader.Level > 0)
            {
                oldValue -= this.RowGroupSublevelIndents[groupHeader.Level - 1];
            }
            // Update the affected values in our table by the amount affected
            double change = newValue - oldValue;
            for (int i = groupHeader.Level; i < groupLevelCount; i++)
            {
                this.RowGroupSublevelIndents[i] += change;
                Debug.Assert(this.RowGroupSublevelIndents[i] >= 0);
            }

            EnsureRowGroupSpacerColumnWidth(groupLevelCount);
        }
        internal void OnRowGroupHeaderToggled(DataGridRowGroupHeader groupHeader, Visibility newVisibility, bool setCurrent)
        {
            Debug.Assert(groupHeader.RowGroupInfo.CollectionViewGroup.ItemCount > 0);

            if (!this.CommitEdit())
            {
                return;
            }

            if (setCurrent && this.CurrentSlot != groupHeader.RowGroupInfo.Slot)
            {
                // Most of the time this is set by the MouseLeftButtonDown handler but validation could cause that code path to fail
                UpdateSelectionAndCurrency(this.CurrentColumnIndex, groupHeader.RowGroupInfo.Slot, DataGridSelectionAction.SelectCurrent, false /*scrollIntoView*/);
            }

            UpdateRowGroupVisibility(groupHeader.RowGroupInfo, newVisibility, true /*isDisplayed*/);

            ComputeScrollBarsLayout();
            // We need force arrange since our Scrollings Rows could update without automatically triggering layout
            InvalidateRowsArrange();
        }
 private void RefreshRowGroupHeaders()
 {
     if (this.DataConnection.CollectionView != null
         && this.DataConnection.CollectionView.CanGroup
         && this.DataConnection.CollectionView.Groups != null
         && this.DataConnection.CollectionView.GroupDescriptions != null
         && this.DataConnection.CollectionView.GroupDescriptions.Count > 0)
     {
         // Initialize our array for the height of the RowGroupHeaders by Level.
         // If the Length is the same, we can reuse the old array
         int groupLevelCount = this.DataConnection.CollectionView.GroupDescriptions.Count;
         if (_rowGroupHeightsByLevel == null || _rowGroupHeightsByLevel.Length != groupLevelCount)
         {
             _rowGroupHeightsByLevel = new double[groupLevelCount];
             for (int i = 0; i < groupLevelCount; i++)
             {
                 // Default height for now, the actual heights are updated as the RowGroupHeaders
                 // are added and measured
                 _rowGroupHeightsByLevel[i] = DATAGRID_defaultRowHeight;
             }
         }
         if (this.RowGroupSublevelIndents == null || this.RowGroupSublevelIndents.Length != groupLevelCount)
         {
             this.RowGroupSublevelIndents = new double[groupLevelCount];
             double indent;
             for (int i = 0; i < groupLevelCount; i++)
             {
                 DataGridRowGroupHeader rowGroupHeader = null;
                 indent = DATAGRID_defaultRowGroupSublevelIndent;
                 if (i < this.RowGroupHeaderStyles.Count && this.RowGroupHeaderStyles[i] != null)
                 {
                     // Due to Silverlight Bugs 22038, we have to actually set the Style to read
                     // setter values instead of simply enumerating through the setters
                     if (rowGroupHeader == null)
                     {
                         rowGroupHeader = new DataGridRowGroupHeader();
                     }
                     rowGroupHeader.Style = this.RowGroupHeaderStyles[i];
                     if (rowGroupHeader.SublevelIndent != DataGrid.DATAGRID_defaultRowGroupSublevelIndent)
                     {
                         indent = rowGroupHeader.SublevelIndent;
                     }
                 }
                 this.RowGroupSublevelIndents[i] = indent;
                 if (i > 0)
                 {
                     this.RowGroupSublevelIndents[i] += this.RowGroupSublevelIndents[i - 1];
                 }
             }
         }
         EnsureRowGroupSpacerColumnWidth(groupLevelCount);
     }
 }
 internal void AddRecylableRowGroupHeader(DataGridRowGroupHeader groupHeader)
 {
     Debug.Assert(!_recyclableGroupHeaders.Contains(groupHeader));
     groupHeader.IsRecycled = true;
     _recyclableGroupHeaders.Push(groupHeader);
 }
Beispiel #14
0
 public static void SetContentTemplate(DataGridRowGroupHeader ui, DataTemplate value)
 {
     ui.SetValue(ContentTemplateProperty, value);
 }
Beispiel #15
0
 public static DataTemplate GetContentTemplate(DataGridRowGroupHeader ui)
 {
     return (DataTemplate)ui.GetValue(ContentTemplateProperty);
 }
 internal void AddRecylableRowGroupHeader(DataGridRowGroupHeader groupHeader)
 {
     Debug.Assert(!_recyclableGroupHeaders.Contains(groupHeader));
     groupHeader.IsRecycled = true;
     _recyclableGroupHeaders.Push(groupHeader);
 }