System.Windows.DependencyObject.ClearValue C# (CSharp) Method

ClearValue() public method

public ClearValue ( DependencyProperty dp ) : void
dp DependencyProperty
return void
        public void ClearValue(DependencyProperty dp)
        {
            if (IsSealed)
                throw new InvalidOperationException ("Cannot manipulate property values on a sealed DependencyObject");

            properties[dp] = null;
        }

Same methods

DependencyObject::ClearValue ( System.Windows.DependencyPropertyKey key ) : void

Usage Example

Example #1
0
 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);
                     });
                 }
             }
         }
     }
 }
All Usage Examples Of System.Windows.DependencyObject::ClearValue