本文整理汇总了C#中System.Windows.DependencyObject.ClearValue方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyObject.ClearValue方法的具体用法?C# DependencyObject.ClearValue怎么用?C# DependencyObject.ClearValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.DependencyObject
的用法示例。
在下文中一共展示了DependencyObject.ClearValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RebindInactiveBindings
public static void RebindInactiveBindings(DependencyObject dependencyObject)
{
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(dependencyObject.GetType()))
{
var dpd = DependencyPropertyDescriptor.FromProperty(property);
if (dpd != null)
{
var binding = BindingOperations.GetBindingExpressionBase(dependencyObject, dpd.DependencyProperty);
if (binding != null)
{
//if (property.Name == "DataContext" || binding.HasError || binding.Status != BindingStatus.Active)
{
// Ensure that no pending calls are in the dispatcher queue
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.SystemIdle, (Action) delegate
{
// Remove and add the binding to re-trigger the binding error
dependencyObject.ClearValue(dpd.DependencyProperty);
BindingOperations.SetBinding(dependencyObject, dpd.DependencyProperty,
binding.ParentBindingBase);
});
}
}
}
}
}
示例2: OnAttachChanged
private static void OnAttachChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
Action<System.Windows.Interactivity.TriggerBase> action = null;
System.Windows.Interactivity.TriggerCollection allTriggers;
if (e.NewValue != e.OldValue)
{
System.Windows.Interactivity.TriggerBase[] enumerable = (System.Windows.Interactivity.TriggerBase[]) d.GetValue(MessageTriggersProperty);
allTriggers = Interaction.GetTriggers(d);
if (enumerable != null)
{
if (action == null)
{
action = (Action<System.Windows.Interactivity.TriggerBase>) (x => allTriggers.Remove(x));
}
enumerable.Apply<System.Windows.Interactivity.TriggerBase>(action);
}
System.Windows.Interactivity.TriggerBase[] baseArray2 = Parser.Parse(d, e.NewValue as string).ToArray<System.Windows.Interactivity.TriggerBase>();
baseArray2.Apply<System.Windows.Interactivity.TriggerBase>(new Action<System.Windows.Interactivity.TriggerBase>(allTriggers.Add));
if (baseArray2.Length > 0)
{
d.SetValue(MessageTriggersProperty, baseArray2);
}
else
{
d.ClearValue(MessageTriggersProperty);
}
}
}
示例3: TargetPropertyChangedCallback
private static void TargetPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (e.NewValue == null)
d.ClearValue(Storyboard.TargetPropertyProperty);
else
Storyboard.SetTargetProperty((Timeline)d, new System.Windows.PropertyPath((DependencyProperty)e.NewValue));
}
示例4: ClearBinding
/// <summary>
/// Clears a binding. This method implements the ClearBinding for both WPF and Silverlight.
/// </summary>
/// <param name="dependencyObject">The dependency object.</param>
/// <param name="dependencyProperty">The dependency property.</param>
public static void ClearBinding(DependencyObject dependencyObject, DependencyProperty dependencyProperty)
{
#if NET
BindingOperations.ClearBinding(dependencyObject, dependencyProperty);
#else
// Other platforms do not support ClearBinding, then we use ClearValue
dependencyObject.ClearValue(dependencyProperty);
#endif
}
示例5: UpdateBehavior
private void UpdateBehavior(DependencyObject host, IBehavior behavior)
{
if(behavior.IsApplicable())
{
behavior.Update();
}
else
{
host.ClearValue(_property);
behavior.Detach();
}
}
示例6: OnScopeForChanged
private static void OnScopeForChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (((InputTypeCollection)e.NewValue)?.IsInputType(d) == true)
{
if (GetErrors(d) == null)
{
SetErrors(d, ErrorNode.CreateFor(d));
}
}
else if (((InputTypeCollection)e.OldValue)?.IsInputType(d) == true)
{
d.ClearValue(ErrorsPropertyKey);
}
}
示例7: OnToolTipChanged
private static void OnToolTipChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
// clean up any old tooltip value
if (null != e.OldValue)
{
var oldTT = d.GetValue(ToolTipService.ToolTipProperty) as ToolTip;
// detach our tooltip value from the object
d.ClearValue(ToolTipService.ToolTipProperty);
if (null != oldTT)
{
NameScope.SetNameScope(oldTT, null);
if (oldTT.Tag == AutoGeneratedId)
oldTT.Content = null;
oldTT.Initialized -= NewTTInitialized;
}
}
// if we're getting a new tooltip then initialize the tooltip
// property of the associated object
if (null == e.NewValue) return;
var newTT = e.NewValue as ToolTip ?? new ToolTip {Tag = AutoGeneratedId, Content = e.NewValue};
// if the value isn't a tooltip then create one around it
// so we can bind the datacontext and provide a namescope
d.SetValue(ToolTipService.ToolTipProperty, newTT);
// provide a temporary namescope so we can handle any element name bindings
NameScope.SetNameScope(newTT, new NameScopeHelper(d));
// during the BamlRecordReader's PushContext, the tooltip didn't have
// a namescope so we need to make sure we remove the namescope before
// the PopContext or else the reader will try to push too much off
// the stack and an exception will occur. the Initialized event of
// the associated element is sufficient to do this. an alternative
// approach would be to use a custom tooltip that implements INameScope
// so that the tooltip always has a namescope at the Push and PopContext
// points.
newTT.Initialized += NewTTInitialized;
}
示例8: CreateHandler
static void CreateHandler(DependencyObject element, DependencyProperty property)
{
var focusMover = element.GetValue(FrameworkElement.DataContextProperty) as IFocusMover;
if (focusMover == null)
{
var handler = element.GetValue(MoveFocusSinkProperty) as MoveFocusSink;
if (handler != null)
{
handler.ReleaseReferences();
element.ClearValue(MoveFocusSinkProperty);
}
}
else
{
var handler = new MoveFocusSink(element as UIElement, property);
focusMover.MoveFocus += handler.HandleMoveFocus;
element.SetValue(MoveFocusSinkProperty, handler);
}
}
示例9: RemoveLoadedCallback
/// <summary>
/// Remove the loaded callback from the MediaContext queue
/// </summary>
internal static void RemoveLoadedCallback(DependencyObject d, object[] loadedPending)
{
Debug.Assert(d is FrameworkElement || d is FrameworkContentElement);
if (loadedPending != null)
{
Debug.Assert(loadedPending.Length == 3);
// Clear the LoadedPending property
d.ClearValue(FrameworkElement.LoadedPendingPropertyKey);
// If the dispatcher operation is pending abort it
DispatcherOperation operation = (DispatcherOperation)loadedPending[1];
if (operation.Status == DispatcherOperationStatus.Pending)
{
operation.Abort();
}
// Remove the pending loaded information from the MediaContext's pending
// LoadedOrUnloadedCallbacks list
MediaContext.From(d.Dispatcher).RemoveLoadedOrUnloadedCallback((LoadedOrUnloadedOperation)loadedPending[0]);
}
}
示例10: AnimateProperty
private static void AnimateProperty(DependencyObject target, DependencyProperty property, DoubleAnimation animation, EventHandler animationDone)
{
if (IsAnimationEnabled)
{
((IAnimatable)target).BeginAnimation(property, animation);
}
else
{
((IAnimatable)target).BeginAnimation(property, null);
if (animation.To != null)
{
target.SetValue(property, animation.To);
}
else
{
target.ClearValue(property);
}
if (animationDone != null)
{
animationDone(target, EventArgs.Empty);
}
}
}
示例11: ClearOriginalValue
private static void ClearOriginalValue(DependencyObject obj)
{
obj.ClearValue(OriginalValueProperty);
}
示例12: SetKinectRegion
public static void SetKinectRegion(DependencyObject obj, KinectRegion value)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (value == null)
{
obj.ClearValue(KinectRegionProperty);
}
else
{
obj.SetValue(KinectRegionProperty, value);
}
}
示例13: SynchronizeValue
private static void SynchronizeValue(DependencyProperty dp, DependencyObject parent, DependencyObject child)
{
if (IsDefaultValue(dp, parent))
{
child.ClearValue(dp);
}
else
{
object value = parent.GetValue(dp);
child.SetValue(dp, value);
}
}
示例14: ClearPseudoInheritedProperties
internal static void ClearPseudoInheritedProperties(DependencyObject child)
{
if (child != null)
{
child.ClearValue(RibbonControlService.IsInQuickAccessToolBarPropertyKey);
child.ClearValue(RibbonControlService.IsInControlGroupPropertyKey);
child.ClearValue(RibbonControlService.ControlSizeDefinitionProperty);
}
}
示例15: ClearAdditional
public static void ClearAdditional(DependencyObject dependencyObject)
{
if (dependencyObject != null)
{
dependencyObject.ClearValue (AdditionalProperty);
}
}