本文整理汇总了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);
}
示例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);
}