本文整理汇总了C#中UIElement.ClearStyledValues方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.ClearStyledValues方法的具体用法?C# UIElement.ClearStyledValues怎么用?C# UIElement.ClearStyledValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIElement
的用法示例。
在下文中一共展示了UIElement.ClearStyledValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyStylesInternal
/// <summary>
/// Applies styles to the specified element.
/// </summary>
/// <param name="element">The element to which to apply styles.</param>
private void ApplyStylesInternal(UIElement element)
{
element.ClearStyledValues(false);
// Gather styles from document
var selector = default(UvssSelector);
foreach (var rule in rules)
{
if (!rule.MatchesElement(element, out selector))
continue;
var uv = element.Ultraviolet;
var navexp = NavigationExpression.FromUvssNavigationExpression(uv, rule.NavigationExpression);
foreach (var style in rule.Styles)
{
prioritizer.Add(uv, selector, navexp, style);
}
foreach (var trigger in rule.Triggers)
{
prioritizer.Add(uv, selector, navexp, trigger);
}
}
// Apply styles to element
prioritizer.Apply(element);
}
示例2: ApplyStylesInternal
/// <summary>
/// Applies styles to the specified element.
/// </summary>
/// <param name="element">The element to which to apply styles.</param>
private void ApplyStylesInternal(UIElement element)
{
element.ClearStyledValues(false);
// Prioritize styles from name.
var frameworkElement = element as FrameworkElement;
if (frameworkElement != null && !String.IsNullOrEmpty(frameworkElement.Name))
{
var ruleSetsByName = GetRuleSetsByName(frameworkElement.Name, onlyIfExists: true);
if (ruleSetsByName != null)
{
foreach (var categorized in ruleSetsByName)
AddRuleSetToPrioritizer(element, categorized.Selector, categorized.RuleSet, categorized.Index);
}
}
// Prioritize styles from class.
foreach (var @class in element.Classes)
{
var ruleSetsByCategory = GetRuleSetsByClass(@class, onlyIfExists: true);
if (ruleSetsByCategory != null)
{
foreach (var categorized in ruleSetsByCategory)
AddRuleSetToPrioritizer(element, categorized.Selector, categorized.RuleSet, categorized.Index);
}
}
// Prioritize rules from type.
var ruleSetsByType = GetRuleSetsByType(element.UvmlName, onlyIfExists: true);
if (ruleSetsByType != null)
{
foreach (var categorized in ruleSetsByType)
AddRuleSetToPrioritizer(element, categorized.Selector, categorized.RuleSet, categorized.Index);
}
// Prioritize uncategorized styles.
foreach (var categorized in ruleSetsWithoutCategory)
AddRuleSetToPrioritizer(element, categorized.Selector, categorized.RuleSet, categorized.Index);
// Apply styles to element
prioritizer.Apply(element);
}