// protected internal void RemoveLogicalChild(object child) { if (child != null) { // It is invalid to modify the children collection that we // might be iterating during a property invalidation tree walk. if (IsLogicalChildrenIterationInProgress) { throw new InvalidOperationException(SR.Get(SRID.CannotModifyLogicalChildrenDuringTreeWalk)); } // Child is present FrameworkObject fo = new FrameworkObject(child as DependencyObject); if (fo.Parent == this) { fo.ChangeLogicalParent(null); } // This could have been the last child, so check if we have any more children IEnumerator children = LogicalChildren; // if null, there are no children. if (children == null) { HasLogicalChildren = false; } else { // If we can move next, there is at least one child HasLogicalChildren = children.MoveNext(); } } }
// Token: 0x06005CD0 RID: 23760 RVA: 0x001A1E64 File Offset: 0x001A0064 private static object OnCoerceContent(DependencyObject d, object baseValue) { DataGridColumnHeader dataGridColumnHeader = d as DataGridColumnHeader; object coercedTransferPropertyValue = DataGridHelper.GetCoercedTransferPropertyValue(dataGridColumnHeader, baseValue, ContentControl.ContentProperty, dataGridColumnHeader.Column, DataGridColumn.HeaderProperty); FrameworkObject frameworkObject = new FrameworkObject(coercedTransferPropertyValue as DependencyObject); if (frameworkObject.Parent != null && frameworkObject.Parent != dataGridColumnHeader) { frameworkObject.ChangeLogicalParent(null); } return(coercedTransferPropertyValue); }
// protected internal void AddLogicalChild(object child) { if (child != null) { // It is invalid to modify the children collection that we // might be iterating during a property invalidation tree walk. if (IsLogicalChildrenIterationInProgress) { throw new InvalidOperationException(SR.Get(SRID.CannotModifyLogicalChildrenDuringTreeWalk)); } // Now that the child is going to be added, the FE/FCE construction is considered finished, // so we do not expect a change of InheritanceBehavior property, // so we can pick up properties from styles and resources. TryFireInitialized(); bool exceptionThrown = true; try { HasLogicalChildren = true; // Child is present; reparent him to this element FrameworkObject fo = new FrameworkObject(child as DependencyObject); fo.ChangeLogicalParent(this); exceptionThrown = false; } finally { if (exceptionThrown) { // // Consider doing this... //RemoveLogicalChild(child); } } } }
/// <summary> /// Coerces the Content property. We're choosing a value between Column.Header and the Content property on ColumnHeader. /// </summary> private static object OnCoerceContent(DependencyObject d, object baseValue) { var header = d as DataGridColumnHeader; object content = DataGridHelper.GetCoercedTransferPropertyValue( header, baseValue, ContentProperty, header.Column, DataGridColumn.HeaderProperty); // if content is a WPF element with a logical parent, disconnect it now // so that it can be connected to the DGColumnHeader. This happens during // a theme change - see Dev11 146729. FrameworkObject fo = new FrameworkObject(content as DependencyObject); if (fo.Parent != null && fo.Parent != header) { fo.ChangeLogicalParent(null); } return(content); }