本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}