当前位置: 首页>>代码示例>>C#>>正文


C# DependencyObject.ClearValue方法代码示例

本文整理汇总了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);
                     });
                 }
             }
         }
     }
 }
开发者ID:x-skywalker,项目名称:CodeMask,代码行数:25,代码来源:BindingHelper.cs

示例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);
         }
     }
 }
开发者ID:BigBri41,项目名称:TWCTVWindowsPhone,代码行数:28,代码来源:Message.cs

示例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));
 }
开发者ID:Titaye,项目名称:SLExtensions,代码行数:7,代码来源:StoryboardExtensions.cs

示例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
        }
开发者ID:justdude,项目名称:DbExport,代码行数:14,代码来源:BindingHelper.cs

示例5: UpdateBehavior

		private void UpdateBehavior(DependencyObject host, IBehavior behavior)
		{
			if(behavior.IsApplicable())
			{
				behavior.Update();
			}
			else
			{
				host.ClearValue(_property);

				behavior.Detach();
			}
		}
开发者ID:gitter-badger,项目名称:vc-community-1.x,代码行数:13,代码来源:AttachedBehavior.cs

示例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);
     }
 }
开发者ID:gitter-badger,项目名称:Gu.Wpf.ValidationScope,代码行数:14,代码来源:Scope.cs

示例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;
  }
开发者ID:dggowda047,项目名称:itraacv2-1,代码行数:44,代码来源:BindableToolTip.cs

示例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);
     }
 }
开发者ID:austinedeveloper,项目名称:Real-Estate-WPF-app,代码行数:19,代码来源:FocusController.cs

示例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]);
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:26,代码来源:BroadcastEventHelper.cs

示例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);
                }
            }
        }
开发者ID:newHopeLJP,项目名称:WPFContrib,代码行数:24,代码来源:Animator.cs

示例11: ClearOriginalValue

 private static void ClearOriginalValue(DependencyObject obj)
 {
     obj.ClearValue(OriginalValueProperty);
 }
开发者ID:JianwenSun,项目名称:cc,代码行数:4,代码来源:DataGridColumn.cs

示例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);
            }
        }
开发者ID:dolphinlcj,项目名称:motion-paint,代码行数:16,代码来源:KinectRegion.cs

示例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);
     } 
 }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:12,代码来源:TreeViewItem.cs

示例14: ClearPseudoInheritedProperties

 internal static void ClearPseudoInheritedProperties(DependencyObject child)
 {
     if (child != null)
     {
         child.ClearValue(RibbonControlService.IsInQuickAccessToolBarPropertyKey);
         child.ClearValue(RibbonControlService.IsInControlGroupPropertyKey);
         child.ClearValue(RibbonControlService.ControlSizeDefinitionProperty);
     }
 }
开发者ID:kasicass,项目名称:kasicass,代码行数:9,代码来源:RibbonHelper.cs

示例15: ClearAdditional

 public static void ClearAdditional(DependencyObject dependencyObject)
 {
     if (dependencyObject != null)
     {
         dependencyObject.ClearValue (AdditionalProperty);
     }
 }
开发者ID:mrange,项目名称:T4Include,代码行数:7,代码来源:Generated_DependencyProperties.cs


注:本文中的System.Windows.DependencyObject.ClearValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。