/// <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(nameof(dependencyObject)); } if (dependencyProperty == null) { throw new ArgumentNullException(nameof(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)); }
/// <summary>Returns a structure that reports various metadata and property system characteristics of a specified dependency property on a particular <see cref="T:System.Windows.DependencyObject" />.</summary> /// <param name="dependencyObject">The element that contains the <paramref name="dependencyProperty" /> to report information for.</param> /// <param name="dependencyProperty">The identifier for the dependency property to report information for.</param> /// <returns>A <see cref="T:System.Windows.ValueSource" /> structure that reports the specific information.</returns> // Token: 0x060003B9 RID: 953 RVA: 0x0000A968 File Offset: 0x00008B68 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 flag; bool isExpression; bool isAnimated; bool isCoerced; bool isCurrent; BaseValueSourceInternal valueSource = dependencyObject.GetValueSource(dependencyProperty, null, out flag, out isExpression, out isAnimated, out isCoerced, out isCurrent); return(new ValueSource(valueSource, isExpression, isAnimated, isCoerced, isCurrent)); }
private static bool IsDefaultValue(DependencyProperty dp, DependencyObject element) { bool hasModifiers; return element.GetValueSource(dp, null, out hasModifiers) == BaseValueSourceInternal.Default; }
/// <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; }
// 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); }
/// <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); }
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; }
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; }
/// <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; }
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; }