// Token: 0x060046E1 RID: 18145 RVA: 0x001418B8 File Offset: 0x0013FAB8
        internal void PrepareCell(object item, DataGridRow ownerRow, int index)
        {
            this._owner = ownerRow;
            DataGrid dataGridOwner = this._owner.DataGridOwner;

            if (dataGridOwner != null)
            {
                if (index >= 0 && index < dataGridOwner.Columns.Count)
                {
                    DataGridColumn dataGridColumn = dataGridOwner.Columns[index];
                    this.Column   = dataGridColumn;
                    base.TabIndex = dataGridColumn.DisplayIndex;
                }
                if (this.IsEditing)
                {
                    this.IsEditing = false;
                }
                else if (!(base.Content is FrameworkElement))
                {
                    this.BuildVisualTree();
                    if (!this.NeedsVisualTree)
                    {
                        base.Content = item;
                    }
                }
                bool isSelected = dataGridOwner.SelectedCellsInternal.Contains(this);
                this.SyncIsSelected(isSelected);
            }
            DataGridHelper.TransferProperty(this, FrameworkElement.StyleProperty);
            DataGridHelper.TransferProperty(this, DataGridCell.IsReadOnlyProperty);
            base.CoerceValue(UIElement.ClipProperty);
        }
示例#2
0
 /// <summary>
 ///     Called due to the cell's column definition changing.
 ///     Not called due to changes within the current column definition.
 /// </summary>
 /// <remarks>
 ///     Coerces ContentTemplate and ContentTemplateSelector.
 /// </remarks>
 /// <param name="oldColumn">The old column definition.</param>
 /// <param name="newColumn">The new column definition.</param>
 protected virtual void OnColumnChanged(DataGridColumn oldColumn, DataGridColumn newColumn)
 {
     // We need to call BuildVisualTree after changing the column (PrepareCell does this).
     Content = null;
     DataGridHelper.TransferProperty(this, StyleProperty);
     DataGridHelper.TransferProperty(this, IsReadOnlyProperty);
 }
示例#3
0
        /// <summary>
        ///     General notification for DependencyProperty changes from the grid or from columns.
        /// </summary>
        internal void NotifyPropertyChanged(DependencyObject d, string propertyName, DependencyPropertyChangedEventArgs e, DataGridNotificationTarget target)
        {
            DataGridColumn column = d as DataGridColumn;

            if ((column != null) && (column != Column))
            {
                // This notification does not apply to this cell
                return;
            }

            // All the notifications which are to be handled by the cell
            if (DataGridHelper.ShouldNotifyCells(target))
            {
                if (e.Property == DataGridColumn.WidthProperty)
                {
                    DataGridHelper.OnColumnWidthChanged(this, e);
                }
                else if (e.Property == DataGrid.CellStyleProperty || e.Property == DataGridColumn.CellStyleProperty || e.Property == StyleProperty)
                {
                    DataGridHelper.TransferProperty(this, StyleProperty);
                }
                else if (e.Property == DataGrid.IsReadOnlyProperty || e.Property == DataGridColumn.IsReadOnlyProperty || e.Property == IsReadOnlyProperty)
                {
                    DataGridHelper.TransferProperty(this, IsReadOnlyProperty);
                }
                else if (e.Property == DataGridColumn.DisplayIndexProperty)
                {
                    TabIndex = column.DisplayIndex;
                }
                else if (e.Property == DataGrid.IsKeyboardFocusWithinProperty)
                {
                    UpdateVisualState();
                }
            }

            // All the notifications which needs forward to columns
            if (DataGridHelper.ShouldRefreshCellContent(target))
            {
                if (column != null && NeedsVisualTree)
                {
                    if (!string.IsNullOrEmpty(propertyName))
                    {
                        column.RefreshCellContent(this, propertyName);
                    }
                    else if (e != null && e.Property != null)
                    {
                        column.RefreshCellContent(this, e.Property.Name);
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        ///     Prepares a cell for use.
        /// </summary>
        /// <remarks>
        ///     Updates the column reference.
        /// </remarks>
        internal void PrepareCell(object item, DataGridRow ownerRow, int index)
        {
            Debug.Assert(_owner == null || _owner == ownerRow, "_owner should be null before PrepareCell is called or the same value as the ownerRow.");

            _owner = ownerRow;

            DataGrid dataGrid = _owner.DataGridOwner;

            if (dataGrid != null)
            {
                // The index of the container should correspond to the index of the column
                if ((index >= 0) && (index < dataGrid.Columns.Count))
                {
                    // Retrieve the column definition and pass it to the cell container
                    DataGridColumn column = dataGrid.Columns[index];
                    Column   = column;
                    TabIndex = column.DisplayIndex;
                }

                if (IsEditing)
                {
                    // If IsEditing was left on and this container was recycled, reset it here.
                    // Setting this property will result in BuildVisualTree being called.
                    IsEditing = false;
                }
                else if ((Content as FrameworkElement) == null)
                {
                    // If there isn't already a visual tree, then create one.
                    BuildVisualTree();

                    if (!NeedsVisualTree)
                    {
                        Content = item;
                    }
                }

                // Update cell Selection
                bool isSelected = dataGrid.SelectedCellsInternal.Contains(this);
                SyncIsSelected(isSelected);
            }

            DataGridHelper.TransferProperty(this, StyleProperty);
            DataGridHelper.TransferProperty(this, IsReadOnlyProperty);
            CoerceValue(ClipProperty);
        }
        // Token: 0x060046EA RID: 18154 RVA: 0x00141A5C File Offset: 0x0013FC5C
        internal void NotifyPropertyChanged(DependencyObject d, string propertyName, DependencyPropertyChangedEventArgs e, DataGridNotificationTarget target)
        {
            DataGridColumn dataGridColumn = d as DataGridColumn;

            if (dataGridColumn != null && dataGridColumn != this.Column)
            {
                return;
            }
            if (DataGridHelper.ShouldNotifyCells(target))
            {
                if (e.Property == DataGridColumn.WidthProperty)
                {
                    DataGridHelper.OnColumnWidthChanged(this, e);
                }
                else if (e.Property == DataGrid.CellStyleProperty || e.Property == DataGridColumn.CellStyleProperty || e.Property == FrameworkElement.StyleProperty)
                {
                    DataGridHelper.TransferProperty(this, FrameworkElement.StyleProperty);
                }
                else if (e.Property == DataGrid.IsReadOnlyProperty || e.Property == DataGridColumn.IsReadOnlyProperty || e.Property == DataGridCell.IsReadOnlyProperty)
                {
                    DataGridHelper.TransferProperty(this, DataGridCell.IsReadOnlyProperty);
                }
                else if (e.Property == DataGridColumn.DisplayIndexProperty)
                {
                    base.TabIndex = dataGridColumn.DisplayIndex;
                }
                else if (e.Property == UIElement.IsKeyboardFocusWithinProperty)
                {
                    base.UpdateVisualState();
                }
            }
            if (DataGridHelper.ShouldRefreshCellContent(target) && dataGridColumn != null && this.NeedsVisualTree)
            {
                if (!string.IsNullOrEmpty(propertyName))
                {
                    dataGridColumn.RefreshCellContent(this, propertyName);
                    return;
                }
                if (e.Property != null)
                {
                    dataGridColumn.RefreshCellContent(this, e.Property.Name);
                }
            }
        }
 /// <summary>Called when the cell's <see cref="P:System.Windows.Controls.DataGridCell.Column" /> property changes. </summary>
 /// <param name="oldColumn">The old column definition.</param>
 /// <param name="newColumn">The new column definition.</param>
 // Token: 0x060046E7 RID: 18151 RVA: 0x001419DD File Offset: 0x0013FBDD
 protected virtual void OnColumnChanged(DataGridColumn oldColumn, DataGridColumn newColumn)
 {
     base.Content = null;
     DataGridHelper.TransferProperty(this, FrameworkElement.StyleProperty);
     DataGridHelper.TransferProperty(this, DataGridCell.IsReadOnlyProperty);
 }