コード例 #1
0
        internal void OnAncestorChangedInternal(TreeChangeInfo parentTreeState)
        {
            // Cache the IsSelfInheritanceParent flag
            bool wasSelfInheritanceParent = IsSelfInheritanceParent;

            if (parentTreeState.Root != this)
            {
                // Clear the HasStyleChanged flag
                HasStyleChanged     = false;
                HasStyleInvalidated = false;
            }

            // If this is a tree add operation update the ShouldLookupImplicitStyles
            // flag with respect to your parent.
            if (parentTreeState.IsAddOperation)
            {
                FrameworkObject fo =

                    new FrameworkObject(null, this);
                fo.SetShouldLookupImplicitStyles();
            }

            // Invalidate ResourceReference properties
            if (HasResourceReference)
            {
                // This operation may cause a style change and hence should be done before the call to
                // InvalidateTreeDependents as it relies on the HasStyleChanged flag
                TreeWalkHelper.OnResourcesChanged(this, ResourcesChangeInfo.TreeChangeInfo, false);
            }

            // If parent is a FrameworkElement
            // This is also an operation that could change the style
            FrugalObjectList <DependencyProperty> currentInheritableProperties =
                InvalidateTreeDependentProperties(parentTreeState, IsSelfInheritanceParent, wasSelfInheritanceParent);

            // we have inherited properties that changes as a result of the above;
            // invalidation; push that list of inherited properties on the stack
            // for the children to use
            parentTreeState.InheritablePropertiesStack.Push(currentInheritableProperties);


            // Notify the PresentationSource that this element's ancestry may have changed.
            // We only need the ContentElement's because UIElements are taken care of
            // through the Visual class.
            PresentationSource.OnAncestorChanged(this);


            // Call OnAncestorChanged
            OnAncestorChanged();

            // Notify mentees if they exist
            if (PotentiallyHasMentees)
            {
                // Raise the ResourcesChanged Event so that ResourceReferenceExpressions
                // on non-[FE/FCE] listening for this can then update their values
                RaiseClrEvent(FrameworkElement.ResourcesChangedKey, EventArgs.Empty);
            }
        }
コード例 #2
0
        // Token: 0x06000C69 RID: 3177 RVA: 0x0002E674 File Offset: 0x0002C874
        internal static void OnResourcesChanged(DependencyObject d, ResourcesChangeInfo info, bool raiseResourceChangedEvent)
        {
            bool            flag                      = info.Contains(d.DependencyObjectType.SystemType, true);
            bool            isThemeChange             = info.IsThemeChange;
            bool            isStyleResourcesChange    = info.IsStyleResourcesChange;
            bool            isTemplateResourcesChange = info.IsTemplateResourcesChange;
            bool            flag2                     = info.Container == d;
            FrameworkObject frameworkObject           = new FrameworkObject(d);

            if (info.IsResourceAddOperation || info.IsCatastrophicDictionaryChange)
            {
                frameworkObject.SetShouldLookupImplicitStyles();
            }
            if (frameworkObject.IsFE)
            {
                FrameworkElement fe = frameworkObject.FE;
                fe.HasStyleChanged     = false;
                fe.HasStyleInvalidated = false;
                fe.HasTemplateChanged  = false;
                if (info.IsImplicitDataTemplateChange)
                {
                    ContentPresenter contentPresenter = fe as ContentPresenter;
                    if (contentPresenter != null)
                    {
                        contentPresenter.ReevaluateTemplate();
                    }
                }
                if (fe.HasResourceReference)
                {
                    TreeWalkHelper.InvalidateResourceReferences(fe, info);
                    if ((!isStyleResourcesChange && !isTemplateResourcesChange) || !flag2)
                    {
                        TreeWalkHelper.InvalidateStyleAndReferences(d, info, flag);
                    }
                }
                else if (flag && (fe.HasImplicitStyleFromResources || fe.Style == FrameworkElement.StyleProperty.GetMetadata(fe.DependencyObjectType).DefaultValue) && (!isStyleResourcesChange || !flag2))
                {
                    fe.UpdateStyleProperty();
                }
                if (isThemeChange)
                {
                    fe.UpdateThemeStyleProperty();
                }
                if (raiseResourceChangedEvent && fe.PotentiallyHasMentees)
                {
                    fe.RaiseClrEvent(FrameworkElement.ResourcesChangedKey, new ResourcesChangedEventArgs(info));
                    return;
                }
            }
            else
            {
                FrameworkContentElement fce = frameworkObject.FCE;
                fce.HasStyleChanged     = false;
                fce.HasStyleInvalidated = false;
                if (fce.HasResourceReference)
                {
                    TreeWalkHelper.InvalidateResourceReferences(fce, info);
                    if ((!isStyleResourcesChange && !isTemplateResourcesChange) || !flag2)
                    {
                        TreeWalkHelper.InvalidateStyleAndReferences(d, info, flag);
                    }
                }
                else if (flag && (fce.HasImplicitStyleFromResources || fce.Style == FrameworkContentElement.StyleProperty.GetMetadata(fce.DependencyObjectType).DefaultValue) && (!isStyleResourcesChange || !flag2))
                {
                    fce.UpdateStyleProperty();
                }
                if (isThemeChange)
                {
                    fce.UpdateThemeStyleProperty();
                }
                if (raiseResourceChangedEvent && fce.PotentiallyHasMentees)
                {
                    fce.RaiseClrEvent(FrameworkElement.ResourcesChangedKey, new ResourcesChangedEventArgs(info));
                }
            }
        }
コード例 #3
0
        // Token: 0x06000C61 RID: 3169 RVA: 0x0002E1F8 File Offset: 0x0002C3F8
        internal static void InvalidateOnTreeChange(FrameworkElement fe, FrameworkContentElement fce, DependencyObject parent, bool isAddOperation)
        {
            FrameworkObject frameworkObject = new FrameworkObject(parent);

            if (!frameworkObject.IsValid)
            {
                parent = frameworkObject.FrameworkParent.DO;
            }
            FrameworkObject frameworkObject2 = new FrameworkObject(fe, fce);

            if (isAddOperation)
            {
                frameworkObject2.SetShouldLookupImplicitStyles();
            }
            frameworkObject2.Reset(frameworkObject2.TemplatedParent);
            frameworkObject2.HasTemplateChanged = false;
            DependencyObject dependencyObject = (fe != null) ? fe : fce;

            if (fe != null)
            {
                if (fe.IsInitialized && !fe.HasLocalStyle)
                {
                    fe.HasStyleChanged          = false;
                    fe.HasStyleInvalidated      = false;
                    fe.HasTemplateChanged       = false;
                    fe.AncestorChangeInProgress = true;
                    fe.UpdateStyleProperty();
                    fe.AncestorChangeInProgress = false;
                }
            }
            else if (!fce.HasLocalStyle)
            {
                fce.HasStyleChanged          = false;
                fce.HasStyleInvalidated      = false;
                fce.AncestorChangeInProgress = true;
                fce.UpdateStyleProperty();
                fce.AncestorChangeInProgress = false;
            }
            if (TreeWalkHelper.HasChildren(fe, fce))
            {
                FrameworkContextData frameworkContextData = FrameworkContextData.From(dependencyObject.Dispatcher);
                if (frameworkContextData.WasNodeVisited(dependencyObject, TreeWalkHelper.TreeChangeDelegate))
                {
                    return;
                }
                TreeChangeInfo data = new TreeChangeInfo(dependencyObject, parent, isAddOperation);
                PrePostDescendentsWalker <TreeChangeInfo> prePostDescendentsWalker = new PrePostDescendentsWalker <TreeChangeInfo>(TreeWalkPriority.LogicalTree, TreeWalkHelper.TreeChangeDelegate, TreeWalkHelper.TreeChangePostDelegate, data);
                frameworkContextData.AddWalker(TreeWalkHelper.TreeChangeDelegate, prePostDescendentsWalker);
                try
                {
                    prePostDescendentsWalker.StartWalk(dependencyObject);
                    return;
                }
                finally
                {
                    frameworkContextData.RemoveWalker(TreeWalkHelper.TreeChangeDelegate, prePostDescendentsWalker);
                }
            }
            TreeChangeInfo info = new TreeChangeInfo(dependencyObject, parent, isAddOperation);

            TreeWalkHelper.OnAncestorChanged(fe, fce, info);
            bool visitedViaVisualTree = false;

            TreeWalkHelper.OnPostAncestorChanged(dependencyObject, info, visitedViaVisualTree);
        }