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


C# FrameworkContentElement.OnStyleChanged方法代码示例

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


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

示例1: DoStyleInvalidations

        //  ===========================================================================
        //  These methods are invoked when a Property is being
        //  invalidated via a Style/Template
        //  ===========================================================================

        #region InvalidateMethods

        //
        //  This method
        //  1. Is invoked when the StyleProperty is invalidated on a FrameworkElement or
        //     FrameworkContentElement or a sub-class thereof.
        //
        internal static void DoStyleInvalidations(
            FrameworkElement fe,
            FrameworkContentElement fce,
            Style oldStyle,
            Style newStyle)
        {
            Debug.Assert(fe != null || fce != null);

            if (oldStyle != newStyle)
            {
                //
                // Style is changing
                //

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

                // If the style wants to watch for the Loaded and/or Unloaded events, set the
                // flag that says we want to receive it.  Otherwise, if it was set in the old style, clear it.
                StyleHelper.UpdateLoadedFlag( container, oldStyle, newStyle );

                // Set up any per-instance state relating to the new Style
                // We do this here instead of OnStyleInvalidated because
                //  this needs to happen for the *first* Style.
                StyleHelper.UpdateInstanceData(
                    StyleHelper.StyleDataField,
                    fe, fce,
                    oldStyle, newStyle,
                    null /* oldFrameworkTemplate */, null /* newFrameworkTemplate */,
                    (InternalFlags)0);

                // If this new style has resource references (either for the container
                // or for children in the visual tree), then, mark it so that it will
                // not be ignored during resource change invalidations
                if ((newStyle != null) && (newStyle.HasResourceReferences))
                {
                    if (fe != null)
                    {
                        fe.HasResourceReference = true;
                    }
                    else
                    {
                        fce.HasResourceReference = true;
                    }
                }

                FrugalStructList<ContainerDependent> oldContainerDependents =
                    oldStyle != null ? oldStyle.ContainerDependents : StyleHelper.EmptyContainerDependents;

                FrugalStructList<ContainerDependent> newContainerDependents =
                    newStyle != null ? newStyle.ContainerDependents : StyleHelper.EmptyContainerDependents;

                // Propagate invalidation for Style dependents
                FrugalStructList<ContainerDependent> exclusionContainerDependents =
                    new FrugalStructList<ContainerDependent>();
                StyleHelper.InvalidateContainerDependents(container,
                    ref exclusionContainerDependents,
                    ref oldContainerDependents,
                    ref newContainerDependents);

                // Propagate invalidation for resource references that may be
                // picking stuff from the style's ResourceDictionary
                DoStyleResourcesInvalidations(container, fe, fce, oldStyle, newStyle);

                // Notify Style has changed
                // CALLBACK
                if (fe != null)
                {
                    fe.OnStyleChanged(oldStyle, newStyle);
                }
                else
                {
                    fce.OnStyleChanged(oldStyle, newStyle);
                }
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:87,代码来源:StyleHelper.cs


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