当前位置: 首页>>代码示例>>C#>>正文


C# FrameworkContentElement.UpdateStyleProperty方法代码示例

本文整理汇总了C#中System.Windows.FrameworkContentElement.UpdateStyleProperty方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkContentElement.UpdateStyleProperty方法的具体用法?C# FrameworkContentElement.UpdateStyleProperty怎么用?C# FrameworkContentElement.UpdateStyleProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.FrameworkContentElement的用法示例。


在下文中一共展示了FrameworkContentElement.UpdateStyleProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InvalidateOnTreeChange

        /// <summary>
        ///     Invalidate inheritable properties and resource 
        ///     references during a tree change operation. 
        /// </summary>
        internal static void InvalidateOnTreeChange( 
            FrameworkElement        fe,
            FrameworkContentElement fce,
            DependencyObject        parent,
            bool                    isAddOperation) 
        {
            Debug.Assert(fe != null || fce != null, "Node with the tree change notification must be an FE or an FCE."); 
            Debug.Assert(parent != null, "Must have a parent that the current node is connected to or disconnected from."); 

            // If the tree change is for a non-FE/FCE parent then we need to find 
            // the nearest FE/FCE parent inorder to propagate inheritance correctly.
            FrameworkObject parentFO = new FrameworkObject(parent);
            if (!parentFO.IsValid)
            { 
                parent = parentFO.FrameworkParent.DO;
            } 
 
            // We're interested in changes to the Template property that occur during
            // the walk - if the template has changed we don't need to invalidate 
            // template-driven properties a second time.  The HasTemplateChanged property
            // is cleared on the first visit to each node, so that it means "template
            // changed during the walk".  But one relevant node isn't visited during
            // the walk - the templated parent of the initial node.  So we handle that now. 
            FrameworkObject fo = new FrameworkObject(fe, fce);
 
            // Synchronize the ShouldLookupImplicitStyles flag with respect to the parent here 
            // because for the root node of a tree change UpdateStyleProperty happens right here
            // in this method. And we need to have synchrnozed the ShouldLookupImplicitStyles 
            // before we re-query the Style property.

            if (isAddOperation)
            { 
                fo.SetShouldLookupImplicitStyles();
            } 
 
            fo.Reset(fo.TemplatedParent);
            fo.HasTemplateChanged = false; 

            DependencyObject d = (fe != null) ? (DependencyObject)fe : (DependencyObject)fce;

            // during a tree walk to invalidate inherited properties, we typically 
            // call UpdateStyle from FE/FCE.InvalidateTreeDependentProperties.  But
            // for the root element of the tree change, we need to record old values 
            // for inherited properties before we've updated the inheritance parent; 
            // so do the updatestyle here before we record old values so that we
            // capture any updates provided by styles. 
            if (fe != null)
            {
                if (fe.IsInitialized && !fe.HasLocalStyle)
                { 
                    // Clear the HasStyleChanged flag
                    fe.HasStyleChanged = false; 
                    fe.HasStyleInvalidated = false; 
                    fe.HasTemplateChanged = false;
 
                    fe.AncestorChangeInProgress = true;
                    fe.UpdateStyleProperty();
                    fe.AncestorChangeInProgress = false;
                } 
            }
            else 
            { 
                if (!fce.HasLocalStyle)
                { 
                    // Clear the HasStyleChanged flag
                    fce.HasStyleChanged = false;
                    fce.HasStyleInvalidated = false;
 
                    fce.AncestorChangeInProgress = true;
                    fce.UpdateStyleProperty(); 
                    fce.AncestorChangeInProgress = false; 
                }
            } 

            if (HasChildren(fe, fce))
            {
                // Spin up a DescendentsWalker only when 
                // the current node has children to walk
 
                // If there is another tree walk that has already visited the 
                // current node then we do not need to re-walk its sub-tree.
                FrameworkContextData fcdata = FrameworkContextData.From(d.Dispatcher); 
                if (!fcdata.WasNodeVisited(d, TreeChangeDelegate))
                {
                    // The TreeChangeInfo object is used here to track
                    // information that we have because we're doing a tree walk. 
                    TreeChangeInfo parentInfo = new TreeChangeInfo(d, parent, isAddOperation);
 
                    // PrePostDescendentsWalker is used instead of the standard 
                    // DescendentsWalker because we need a "post" callback to know when
                    // to pop the parent's InheritableProperties cache from the stack. 
                    PrePostDescendentsWalker<TreeChangeInfo> walker = new PrePostDescendentsWalker<TreeChangeInfo>(
                        TreeWalkPriority.LogicalTree, TreeChangeDelegate, TreeChangePostDelegate, parentInfo);

                    fcdata.AddWalker(TreeChangeDelegate, walker); 

//.........这里部分代码省略.........
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:101,代码来源:TreeWalkHelper.cs


注:本文中的System.Windows.FrameworkContentElement.UpdateStyleProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。