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


C# DependencyObject.GetValueSource方法代码示例

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


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

示例1: IsDefaultValue

 private static bool IsDefaultValue(DependencyProperty dp, DependencyObject element) 
 {
     bool hasModifiers; 
     return element.GetValueSource(dp, null, out hasModifiers) == BaseValueSourceInternal.Default;
 }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:5,代码来源:TreeViewItem.cs

示例2: HasLocalDataContext

 // return true if DataContext is set locally (not inherited) on DependencyObject
 internal static bool HasLocalDataContext(DependencyObject d)
 {
     bool hasModifiers;
     BaseValueSourceInternal valueSource = d.GetValueSource(FrameworkElement.DataContextProperty, null, out hasModifiers);
     return (valueSource != BaseValueSourceInternal.Inherited) &&
             (valueSource != BaseValueSourceInternal.Default || hasModifiers);
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:8,代码来源:BindingExpression.cs

示例3: HasDefaultOrInheritedValueImpl

        /// <summary>
        /// Return true if the given property is not set locally or from a style 
        /// </summary>
        private static bool HasDefaultOrInheritedValueImpl(DependencyObject d, DependencyProperty dp, 
                                                                bool checkInherited, 
                                                                bool ignoreModifiers)
        { 
            PropertyMetadata metadata = dp.GetMetadata(d);
            bool hasModifiers;
            BaseValueSourceInternal source = d.GetValueSource(dp, metadata, out hasModifiers);
 
            if (source == BaseValueSourceInternal.Default ||
                (checkInherited && source == BaseValueSourceInternal.Inherited)) 
            { 
                if (ignoreModifiers)
                { 
                    // ignore modifiers on FE/FCE, for back-compat
                    if (d is FrameworkElement || d is FrameworkContentElement)
                    {
                        hasModifiers = false; 
                    }
                } 
 
                // a default or inherited value might be animated or coerced.  We should
                // return false in that case - the hasModifiers flag tests this. 
                // (An expression modifier can't apply to a default or inherited value.)
                return !hasModifiers;
            }
 
            return false;
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:31,代码来源:Helper.cs

示例4: GetValueSource

        /// <summary>
        /// Return the source of the value for the given property.
        /// </summary>
        public static ValueSource GetValueSource(DependencyObject dependencyObject, DependencyProperty dependencyProperty)
        {
            if (dependencyObject == null)
                throw new ArgumentNullException("dependencyObject");
            if (dependencyProperty == null)
                throw new ArgumentNullException("dependencyProperty");

            dependencyObject.VerifyAccess();

            bool hasModifiers, isExpression, isAnimated, isCoerced, isCurrent;
            BaseValueSourceInternal source = dependencyObject.GetValueSource(dependencyProperty, null, out hasModifiers, out isExpression, out isAnimated, out isCoerced, out isCurrent);

            return new ValueSource(source, isExpression, isAnimated, isCoerced, isCurrent);
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:17,代码来源:DependencyPropertyHelper.cs

示例5: IsFocusable

        internal static bool IsFocusable(DependencyObject element)
        {
            // CODE 



            if(element == null)
            {
                return false;
            }

            UIElement uie = element as UIElement;
            if(uie != null)
            {
                if(uie.IsVisible == false)
                {
                    return false;
                }
            }

            if((bool)element.GetValue(UIElement.IsEnabledProperty) == false)
            {
                return false;
            }

            // CODE 






            bool hasModifiers = false;
            BaseValueSourceInternal valueSource = element.GetValueSource(UIElement.FocusableProperty, null, out hasModifiers);
            bool focusable = (bool) element.GetValue(UIElement.FocusableProperty);

            if(!focusable && valueSource == BaseValueSourceInternal.Default && !hasModifiers)
            {
                // The Focusable property was not explicitly set to anything.
                // The default value is generally false, but true in a few cases.

                if(FocusManager.GetIsFocusScope(element))
                {
                    // Focus scopes are considered focusable, even if
                    // the Focusable property is false.
                    return true;
                }
                else if(uie != null && uie.InternalVisualParent == null)
                {
                    PresentationSource presentationSource = PresentationSource.CriticalFromVisual(uie);
                    if(presentationSource != null)
                    {
                        // A UIElements that is the root of a PresentationSource is considered focusable.
                        return true;
                    }
                }
            }

            return focusable;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:60,代码来源:Keyboard.cs

示例6: BaselineAlignmentIsDefault

        private static bool BaselineAlignmentIsDefault(DependencyObject element) 
        {
            Invariant.Assert(element != null);

            bool hasModifiers; 
            if (element.GetValueSource(Inline.BaselineAlignmentProperty, null, out hasModifiers)
                != BaseValueSourceInternal.Default || hasModifiers) 
            { 
                return false;
            } 
            return true;
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:12,代码来源:DynamicPropertyReader.cs

示例7: GetCollectionValue

        /// <summary>
        /// Helper method to get a collection property value. It returns null (instead of empty collection) 
        /// when the property is not set on the given DO.
        /// </summary> 
        /// <remarks> 
        /// Property system's GetValue() call creates a mutable empty collection when the property is accessed for the first time.
        /// To avoids workingset overhead of those empty collections, we return null instead. 
        /// </remarks>
        private static object GetCollectionValue(DependencyObject element, DependencyProperty property)
        {
            bool hasModifiers; 
            if (element.GetValueSource(property, null, out hasModifiers)
                != BaseValueSourceInternal.Default || hasModifiers) 
            { 
                return element.GetValue(property);
            } 

            return null;
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:19,代码来源:DynamicPropertyReader.cs

示例8: IsDefaultValue

 private static bool IsDefaultValue(DependencyObject dependencyObject, DependencyProperty dependencyProperty)
 {
     bool hasModifiers, isExpression, isAnimated, isCoerced, isCurrent;
     BaseValueSourceInternal source = dependencyObject.GetValueSource(dependencyProperty, null, out hasModifiers, out isExpression, out isAnimated, out isCoerced, out isCurrent);
     return (source == BaseValueSourceInternal.Default) && !isExpression && !isAnimated && !isCoerced;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:6,代码来源:UIElement.cs


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