本文整理汇总了C#中System.Windows.DependencyObject.InvalidateProperty方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyObject.InvalidateProperty方法的具体用法?C# DependencyObject.InvalidateProperty怎么用?C# DependencyObject.InvalidateProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.DependencyObject
的用法示例。
在下文中一共展示了DependencyObject.InvalidateProperty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnIsHiddenPropertyChanged
static void OnIsHiddenPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var dpd = DependencyPropertyDescriptor.FromProperty(UIElement.VisibilityProperty, d.GetType());
if ((bool)e.NewValue) {
EnsureHidden(d);
dpd.AddValueChanged(d, OnVisibilityPropertyChanged);
} else {
dpd.RemoveValueChanged(d, OnVisibilityPropertyChanged);
d.InvalidateProperty(UIElement.VisibilityProperty);
}
}
示例2: InvalidateResourceDependentsForChild
//
// This method
// 1. Invalidates all the resource references set on a template for a given child.
// 2. Returns true if any were found
//
internal static void InvalidateResourceDependentsForChild(
DependencyObject container,
DependencyObject child,
int childIndex,
ResourcesChangeInfo info,
FrameworkTemplate parentTemplate)
{
FrugalStructList<ChildPropertyDependent> resourceDependents = parentTemplate.ResourceDependents;
int count = resourceDependents.Count;
// Invalidate all properties on the given child that
// are being driven via a resource reference in a template
for (int i = 0; i < count; i++)
{
if (resourceDependents[i].ChildIndex == childIndex &&
info.Contains(resourceDependents[i].Name, false /*isImplicitStyleKey*/))
{
DependencyProperty dp = resourceDependents[i].Property;
// Update property on child
child.InvalidateProperty(dp);
// skip remaining dependents for the same property - we only
// need to invalidate once. The list is sorted, so we just need
// to skip until we find a new property.
int dpIndex = dp.GlobalIndex;
while (++i < resourceDependents.Count)
{
if (resourceDependents[i].ChildIndex != childIndex ||
resourceDependents[i].Property.GlobalIndex != dpIndex)
{
break;
}
}
--i; // back up to let the for-loop do its normal increment
}
}
}
示例3: InvalidateContainerDependents
//
// This method
// 1. Invalidates all the properties set on the container's style.
// The value could have been set directly on the Style or via Trigger.
//
internal static void InvalidateContainerDependents(
DependencyObject container,
ref FrugalStructList<ContainerDependent> exclusionContainerDependents,
ref FrugalStructList<ContainerDependent> oldContainerDependents,
ref FrugalStructList<ContainerDependent> newContainerDependents)
{
// Invalidate all properties on the container that were being driven via the oldStyle
int count = oldContainerDependents.Count;
for (int i = 0; i < count; i++)
{
DependencyProperty dp = oldContainerDependents[i].Property;
// Invalidate the property only if it is not locally set
if (!IsSetOnContainer(dp, ref exclusionContainerDependents, false /*alsoFromTriggers*/))
{
// call GetValueCore to get value from Style/Template
container.InvalidateProperty(dp);
}
}
// Invalidate all properties on the container that will be driven via the newStyle
count = newContainerDependents.Count;
if (count > 0)
{
FrameworkObject fo = new FrameworkObject(container);
for (int i = 0; i < count; i++)
{
DependencyProperty dp = newContainerDependents[i].Property;
// Invalidate the property only if it
// - is not a part of oldContainerDependents and
// - is not locally set
if (!IsSetOnContainer(dp, ref exclusionContainerDependents, false /*alsoFromTriggers*/) &&
!IsSetOnContainer(dp, ref oldContainerDependents, false /*alsoFromTriggers*/))
{
ApplyStyleOrTemplateValue(fo, dp);
}
}
}
}