本文整理汇总了C#中MS.Internal.FrameworkObject.ChangeSubtreeHasLoadedChangedHandler方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkObject.ChangeSubtreeHasLoadedChangedHandler方法的具体用法?C# FrameworkObject.ChangeSubtreeHasLoadedChangedHandler怎么用?C# FrameworkObject.ChangeSubtreeHasLoadedChangedHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MS.Internal.FrameworkObject
的用法示例。
在下文中一共展示了FrameworkObject.ChangeSubtreeHasLoadedChangedHandler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateHasLoadedChangeHandlerFlagInAncestry
/// <summary>
/// This is a recursive function that walks up the tree Adding or Removing
/// HasLoadedChangeHander bits. It also inits the IsLoadedCache on Add.
/// </summary>
/// <param name="d">
/// Node to update
/// </param>
/// <param name="addHandler">
/// Is it an AddHandler/ Add Child with Handler Operation
/// </param>
private static void UpdateHasLoadedChangeHandlerFlagInAncestry(DependencyObject d, bool addHandler)
{
FrameworkObject fo = new FrameworkObject(d);
if (!addHandler)
{
if ( AreThereLoadedChangeHandlersInSubtree(ref fo) )
return; // done
}
if (fo.IsValid)
{
if (fo.SubtreeHasLoadedChangeHandler != addHandler)
{
DependencyObject coreParent = (fo.IsFE) ? VisualTreeHelper.GetParent(fo.FE) : null;
DependencyObject logicalParent = fo.Parent;
DependencyObject parent = null;
fo.SubtreeHasLoadedChangeHandler = addHandler;
// Propagate the change to your visual ancestry
if (coreParent != null)
{
UpdateHasLoadedChangeHandlerFlagInAncestry(coreParent, addHandler);
parent = coreParent;
}
// Propagate the change to your logical ancestry
if (logicalParent != null && logicalParent != coreParent)
{
UpdateHasLoadedChangeHandlerFlagInAncestry(logicalParent, addHandler);
if (fo.IsFCE)
parent = logicalParent;
}
// Propagate the change to your mentor, if any
if (logicalParent == null && coreParent == null)
{
parent = Helper.FindMentor(fo.DO.InheritanceContext);
if (parent != null)
{
fo.ChangeSubtreeHasLoadedChangedHandler(parent);
}
}
if(addHandler)
{
// The HasLoadedChangeHandler flag is used for two purposes.
// 1. To indicate that the sub-tree starting at the current node has
// handlers for Loaded / Unloaded event. So broadcast logic
// can walk down that path to fire the events.
// 2. To indicate that the IsLoaded cache on the node is valid.
// If we are adding a handler:
// On the POP side of the recursion, as we come back down from the root,
// pull the value of IsLoadedCache from the parent in to the child.
if (fo.IsFE)
{
UpdateIsLoadedCache(fo.FE, parent);
}
else
{
UpdateIsLoadedCache(fo.FCE, parent);
}
}
}
}
else // neither a FE or an FCE
{
DependencyObject coreParent = null;
Visual v;
Visual3D v3D;
ContentElement ce;
// This is neither an FE nor and FCE
// Propagate the change to your visual ancestry
if ((v = d as Visual) != null)
{
coreParent = VisualTreeHelper.GetParent(v);
}
else if ((ce = d as ContentElement) != null)
{
coreParent = ContentOperations.GetParent(ce);
}
else if ((v3D = d as Visual3D) != null)
{
coreParent = VisualTreeHelper.GetParent(v3D);
}
if (coreParent != null)
//.........这里部分代码省略.........