本文整理汇总了C#中MS.Internal.FrameworkObject.ChangeLogicalParent方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkObject.ChangeLogicalParent方法的具体用法?C# FrameworkObject.ChangeLogicalParent怎么用?C# FrameworkObject.ChangeLogicalParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MS.Internal.FrameworkObject
的用法示例。
在下文中一共展示了FrameworkObject.ChangeLogicalParent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveLogicalChild
protected internal void RemoveLogicalChild(object child)
{
if (child == null)
return;
if (this.IsLogicalChildrenIterationInProgress)
throw new InvalidOperationException(System.Windows.SR.Get("CannotModifyLogicalChildrenDuringTreeWalk"));
FrameworkObject frameworkObject = new FrameworkObject(child as DependencyObject);
if (frameworkObject.Parent == this)
frameworkObject.ChangeLogicalParent((DependencyObject) null);
IEnumerator logicalChildren = this.LogicalChildren;
if (logicalChildren == null)
this.HasLogicalChildren = false;
else
this.HasLogicalChildren = logicalChildren.MoveNext();
}
示例2: RemoveLogicalChild
//
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();
}
}
}
示例3: OnCoerceContent
/// <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;
}
示例4: AddLogicalChild
//
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);
}
}
}
}