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


C# Style.CheckTargetType方法代码示例

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


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

示例1: UpdateStyleCache

        //  ===========================================================================
        //  These methods are invoked when a Style/Template cache needs to be updated
        //  ===========================================================================

        #region UpdateCache

        //
        //  This method
        //  1. Updates the style cache for the given fe/fce
        //
        internal static void UpdateStyleCache(
            FrameworkElement        fe,
            FrameworkContentElement fce,
            Style                   oldStyle,
            Style                   newStyle,
            ref Style               styleCache)
        {
            Debug.Assert(fe != null || fce != null);

            if (newStyle != null)
            {
                // We have a new style.  Make sure it's targeting the right
                // type, and then seal it.

                DependencyObject d = fe;
                if (d == null)
                {
                    d = fce;
                }
                newStyle.CheckTargetType(d);
                newStyle.Seal();
            }

            styleCache = newStyle;

            // Do style property invalidations. Note that some of the invalidations may be callouts
            // that could turn around and query the style property on this node. Hence it is essential
            // to update the style cache before we do this operation.
            StyleHelper.DoStyleInvalidations(fe, fce, oldStyle, newStyle);

            // Now look for triggers that might want their EnterActions or ExitActions
            //  to run immediately.
            StyleHelper.ExecuteOnApplyEnterExitActions(fe, fce, newStyle, StyleDataField);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:44,代码来源:StyleHelper.cs

示例2: UpdateThemeStyleCache

        //
        //  This method
        //  1. Updates the theme style cache for the given fe/fce
        //
        internal static void UpdateThemeStyleCache(
            FrameworkElement        fe,
            FrameworkContentElement fce,
            Style                   oldThemeStyle,
            Style                   newThemeStyle,
            ref Style               themeStyleCache)
        {
            Debug.Assert(fe != null || fce != null);

            if (newThemeStyle != null)
            {
                DependencyObject d = fe;
                if (d == null)
                {
                    d = fce;
                }
                newThemeStyle.CheckTargetType(d);
                newThemeStyle.Seal();

#pragma warning disable 6503
                // Check if the theme style has the OverridesDefaultStyle  property set on the target tag or any of its
                // visual triggers. It is an error to specify the OverridesDefaultStyle  in your own ThemeStyle.
                if (StyleHelper.IsSetOnContainer(FrameworkElement.OverridesDefaultStyleProperty, ref newThemeStyle.ContainerDependents, true))
                {
                    throw new InvalidOperationException(SR.Get(SRID.CannotHaveOverridesDefaultStyleInThemeStyle));
                }
                // Check if the theme style has EventHandlers set on the target tag or int its setter collection.
                // We do not support EventHandlers in a ThemeStyle
                if (newThemeStyle.HasEventSetters)
                {
                    throw new InvalidOperationException(SR.Get(SRID.CannotHaveEventHandlersInThemeStyle));
                }
#pragma warning restore 6503
            }

            themeStyleCache = newThemeStyle;

            Style style = null;

            if (fe != null)
            {
                if(ShouldGetValueFromStyle ( FrameworkElement.DefaultStyleKeyProperty ) )
                {
                    style = fe.Style;
                }
            }
            else
            {
                if(ShouldGetValueFromStyle ( FrameworkContentElement.DefaultStyleKeyProperty ) )
                {
                    style = fce.Style;
                }
            }

            // Do theme style property invalidations. Note that some of the invalidations may be callouts
            // that could turn around and query the theme style property on this node. Hence it is essential
            // to update the theme style cache before we do this operation.
            StyleHelper.DoThemeStyleInvalidations(fe, fce, oldThemeStyle, newThemeStyle, style);

            // Now look for triggers that might want their EnterActions or ExitActions
            //  to run immediately.
            StyleHelper.ExecuteOnApplyEnterExitActions(fe, fce, newThemeStyle, ThemeStyleDataField);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:67,代码来源:StyleHelper.cs


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