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


C# DependencyObject.ClearValue方法代码示例

本文整理汇总了C#中DependencyObject.ClearValue方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyObject.ClearValue方法的具体用法?C# DependencyObject.ClearValue怎么用?C# DependencyObject.ClearValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DependencyObject的用法示例。


在下文中一共展示了DependencyObject.ClearValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ClearFriendlyName

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

示例2: ClearData

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

示例3: UnlinkContainerFromItem

        internal static void UnlinkContainerFromItem(DependencyObject container, object item, IGeneratorHost host)
        {
            // When a container is removed from the tree, its future takes one of
            // two forms:
            //      a) [normal mode] the container becomes eligible for GC
            //      b) [recycling mode] the container joins the recycled list, and
            //          possibly re-enters the tree at some point, usually with a
            //          different item.
            //
            // As Dev10 bug 452669 and some "subtle issues" that arose in the
            // container recycling work illustrate, it's important that the container
            // and its subtree sever their connection to the data item.  Otherwise
            // you can get aliasing - a dead container reacting to the same item as a live
            // container.  Even without aliasing, it's a perf waste for a dead container
            // to continue reacting to its former data item.
            //
            // On the other hand, it's a perf waste to spend too much effort cleaning
            // up the container and its subtree, since they will often just get GC'd
            // in the near future.
            //
            // WPF initially did a full cleanup of the container, removing all properties
            // that were set in PrepareContainerForItem.  This avoided aliasing, but
            // was deemed too expensive, especially for scrolling.  For Windows OS Bug
            // 1445288, all this cleanup work was removed.  This sped up scrolling, but
            // introduced the problems cited in Dev10 452669 and the recycling "subtle
            // issues".  A compromise is needed.
            //
            // The compromise is tell the container to attach to a sentinel item
            // BindingExpressionBase.DisconnectedItem.  We allow this to propagate into the
            // conainer's subtree through properties like DataContext and
            // ContentControl.Content that are normally set by PrepareItemForContainer.
            // A Binding that sees the sentinel as the data item will disconnect its
            // event listeners from the former data item, but will not change its
            // own value or invalidate its target property.  This avoids the cost
            // of re-measuring most of the subtree.

            container.ClearValue(ItemForItemContainerProperty);

            // TreeView virtualization requires that we call ClearContainer before setting
            // the DataContext to "Disconnected".  This gives the TreeViewItems a chance
            // to save "Item values" in the look-aside table, before that table is
            // discarded.   (See Dev10 628778)
            host.ClearContainerForItem(container, item);

            if (container != item)
            {
                DependencyProperty dp = FrameworkElement.DataContextProperty;

                #if DEBUG
                // Some ancient code at this point handled the case when DataContext
                // was set via an Expression (presumably a binding).  I don't think
                // this actually happens any more.  Just in case...
                EntryIndex entryIndex = container.LookupEntry(dp.GlobalIndex);
                Debug.Assert(!container.HasExpression(entryIndex, dp), "DataContext set by expression (unexpectedly)");
                #endif

                container.SetValue(dp, BindingExpressionBase.DisconnectedItem);
            }
        }
开发者ID:mind0n,项目名称:hive,代码行数:59,代码来源:ItemContainerGenerator.cs

示例4: LinkContainerToItem

        // establish the link from the container to the corresponding item
        internal static void LinkContainerToItem(DependencyObject container, object item)
        {
            // always set the ItemForItemContainer property
            container.ClearValue(ItemForItemContainerProperty);
            container.SetValue(ItemForItemContainerProperty, item);

            // for non-direct items, set the DataContext property
            if (container != item)
            {
                #if DEBUG
                // Some ancient code at this point handled the case when DataContext
                // was set via an Expression (presumably a binding).  I don't think
                // this actually happens any more.  Just in case...
                DependencyProperty dp = FrameworkElement.DataContextProperty;
                EntryIndex entryIndex = container.LookupEntry(dp.GlobalIndex);
                Debug.Assert(!container.HasExpression(entryIndex, dp), "DataContext set by expression (unexpectedly)");
                #endif

                container.SetValue(FrameworkElement.DataContextProperty, item);
            }
        }
开发者ID:mind0n,项目名称:hive,代码行数:22,代码来源:ItemContainerGenerator.cs

示例5: OnAttachChanged

        static void OnAttachChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
            if (e.NewValue == e.OldValue) {
                return;
            }

            var messageTriggers = (TriggerBase[])d.GetValue(MessageTriggersProperty);

#if WinRT81
            var allTriggers = Interaction.GetBehaviors(d);

            if (messageTriggers != null)
            {
                messageTriggers.OfType<DependencyObject>().Apply(x => allTriggers.Remove(x));
            }

            var newTriggers = Parser.Parse(d, e.NewValue as string).ToArray();
            newTriggers.OfType<DependencyObject>().Apply(allTriggers.Add);
#else
            var allTriggers = Interaction.GetTriggers(d);

             if (messageTriggers != null) {
                messageTriggers.Apply(x => allTriggers.Remove(x));
            }

            var newTriggers = Parser.Parse(d, e.NewValue as string).ToArray();
            newTriggers.Apply(allTriggers.Add);
#endif

            if (newTriggers.Length > 0) {
                d.SetValue(MessageTriggersProperty, newTriggers);
            }
            else {
                d.ClearValue(MessageTriggersProperty);
            }
        }
开发者ID:haoasqui,项目名称:Caliburn.Micro,代码行数:35,代码来源:Message.cs

示例6: ClearBinding

 /// <summary>
 /// Remove data Binding (if any) from a property. 
 /// </summary>
 /// <param name="target">Object from which to remove Binding</param>
 /// <param name="property">Property from which to remove Binding</param> 
 public static void ClearBinding(DependencyObject target, DependencyProperty property)
 {
     if (IsDataBound(target, property))
         target.ClearValue(property);
 }
开发者ID:belyansky,项目名称:Caliburn.Light,代码行数:10,代码来源:BindingHelper.cs

示例7: SetTextFontSize

 private void SetTextFontSize(DependencyObject textElement, DependencyProperty fontSizeProperty)
 {
     double newFontSize = this.FontSize;
     if (double.IsNaN(newFontSize))
     {
         textElement.ClearValue(fontSizeProperty);
     }
     else
     {
         textElement.SetValue(fontSizeProperty, newFontSize);
     }
 }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:12,代码来源:DataGridTextColumn.cs


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