GetMetadata() public method

public GetMetadata ( System.Windows.DependencyObjectType dependencyObjectType ) : System.Windows.PropertyMetadata
dependencyObjectType System.Windows.DependencyObjectType
return System.Windows.PropertyMetadata
 /// <summary>
 ///     Creates a new dependency property descriptor.  A note on perf:  We don't 
 ///     pass the property descriptor down as the default member descriptor here.  Doing
 ///     so takes the attributes off of the property descriptor, which can be costly if they
 ///     haven't been accessed yet.  Instead, we wait until someone needs to access our
 ///     Attributes property and demand create the attributes at that time.
 /// </summary>
 internal DependencyObjectPropertyDescriptor(DependencyProperty dp, Type ownerType)
     : base(string.Concat(dp.OwnerType.Name, ".", dp.Name), null) 
 {
     _dp = dp;
     _componentType = ownerType;
     _metadata = _dp.GetMetadata(ownerType);
 }
Beispiel #2
0
        // Token: 0x06000C65 RID: 3173 RVA: 0x0002E3C0 File Offset: 0x0002C5C0
        internal static FrugalObjectList <DependencyProperty> InvalidateTreeDependentProperties(TreeChangeInfo info, FrameworkElement fe, FrameworkContentElement fce, Style selfStyle, Style selfThemeStyle, ref ChildRecord childRecord, bool isChildRecordValid, bool hasStyleChanged, bool isSelfInheritanceParent, bool wasSelfInheritanceParent)
        {
            DependencyObject dependencyObject = (fe != null) ? fe : fce;
            FrameworkObject  frameworkObject  = new FrameworkObject(fe, fce);
            FrugalObjectList <DependencyProperty> frugalObjectList = info.InheritablePropertiesStack.Peek();
            int num = (frugalObjectList != null) ? frugalObjectList.Count : 0;
            FrugalObjectList <DependencyProperty> frugalObjectList2 = null;

            if (TreeWalkHelper.HasChildren(fe, fce))
            {
                frugalObjectList2 = new FrugalObjectList <DependencyProperty>(num);
            }
            info.ResetInheritableValueIndexer();
            for (int i = 0; i < num; i++)
            {
                DependencyProperty dependencyProperty = frugalObjectList[i];
                PropertyMetadata   metadata           = dependencyProperty.GetMetadata(dependencyObject);
                if (metadata.IsInherited)
                {
                    FrameworkPropertyMetadata frameworkPropertyMetadata = (FrameworkPropertyMetadata)metadata;
                    bool flag = TreeWalkHelper.InvalidateTreeDependentProperty(info, dependencyObject, ref frameworkObject, dependencyProperty, frameworkPropertyMetadata, selfStyle, selfThemeStyle, ref childRecord, isChildRecordValid, hasStyleChanged, isSelfInheritanceParent, wasSelfInheritanceParent);
                    if (flag && frugalObjectList2 != null && (!TreeWalkHelper.SkipNow(frameworkObject.InheritanceBehavior) || frameworkPropertyMetadata.OverridesInheritanceBehavior))
                    {
                        frugalObjectList2.Add(dependencyProperty);
                    }
                }
            }
            return(frugalObjectList2);
        }
 public static void RemovePropertyChanged(DependencyProperty dp, DependencyObjectType type,
                                          DependencyPropertyChangedEventHandler handler)
 {
     var hcpm = dp.GetMetadata(type) as HandleChangesPropertyMetadata;
     if (hcpm == null)
         throw new ArgumentException();
     hcpm.RemovePropertyChanged(type, handler);
 }
        public void CoerceValue(DependencyProperty dp)
        {
            PropertyMetadata pm = dp.GetMetadata(this);

            if (pm.CoerceValueCallback != null)
            {
                pm.CoerceValueCallback(this, GetValue(dp));
            }
        }
        //------------------------------------------------------
        // 
        //  Constructors 
        //
        //----------------------------------------------------- 

        #region Constructors

        /// <summary> 
        ///     Creates a new dependency property descriptor.  A note on perf:  We don't
        ///     pass the property descriptor down as the default member descriptor here.  Doing 
        ///     so gets the attributes off of the property descriptor, which can be costly if they 
        ///     haven't been accessed yet.  Instead, we wait until someone needs to access our
        ///     Attributes property and demand create the attributes at that time. 
        /// </summary>
        private DependencyPropertyDescriptor(PropertyDescriptor property, string name, Type componentType, DependencyProperty dp, bool isAttached) : base(name, null)
        {
            Debug.Assert(property != null || !isAttached, "Demand-load of property descriptor is only supported for direct properties"); 

            _property = property; 
            _componentType = componentType; 
            _dp = dp;
            _isAttached = isAttached; 
            _metadata = _dp.GetMetadata(componentType);
        }
Beispiel #6
0
        // http://www.64bit-world.com/forums/microsoft-public-developer-winfx-avalon/10124-xamlpad-exe-nullreferencexception-winfx-ctp-sept.html
        public object GetValue(DependencyProperty property)
        {
            PropertyMetadata metadata = property.GetMetadata(this.GetType());

            if (metadata.GetValueOverride != null)
            {
                return(metadata.GetValueOverride(this));
            }

            return(GetValueCommon(property, metadata));
        }
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        /// <summary>
        ///     Creates a new dependency property descriptor.  A note on perf:  We don't 
        ///     pass the property descriptor down as the default member descriptor here.  Doing
        ///     so takes the attributes off of the property descriptor, which can be costly if they
        ///     haven't been accessed yet.  Instead, we wait until someone needs to access our
        ///     Attributes property and demand create the attributes at that time.
        /// </summary>
        internal DependencyObjectPropertyDescriptor(PropertyDescriptor property, DependencyProperty dp, Type objectType)
            : base(dp.Name, null) 
        {
            _property = property;
            _dp = dp;

            Debug.Assert(property != null && dp != null);
            Debug.Assert(!(property is DependencyObjectPropertyDescriptor), "Wrapping a DP in a DP");

            _componentType = property.ComponentType;
            _metadata = _dp.GetMetadata(objectType);
        }
Beispiel #8
0
        private IDependencyPropertyValueEntry GetInitializedValueEntry(DependencyProperty dependencyProperty)
        {
            IDependencyPropertyValueEntry entry;

            if (!entries.TryGetValue(dependencyProperty, out entry))
            {
                entry = CreateDependencyPropertyValueEntry(dependencyProperty, dependencyProperty.GetMetadata(GetType()));
                entries.Add(dependencyProperty, entry);
            }

            return(entry);
        }
Beispiel #9
0
        // Token: 0x06000C71 RID: 3185 RVA: 0x0002EDAC File Offset: 0x0002CFAC
        internal static bool IsInheritanceNode(FrameworkContentElement fce, DependencyProperty dp, out InheritanceBehavior inheritanceBehavior)
        {
            inheritanceBehavior = InheritanceBehavior.Default;
            FrameworkPropertyMetadata frameworkPropertyMetadata = dp.GetMetadata(fce.DependencyObjectType) as FrameworkPropertyMetadata;

            if (frameworkPropertyMetadata != null)
            {
                if (fce.InheritanceBehavior != InheritanceBehavior.Default && !frameworkPropertyMetadata.OverridesInheritanceBehavior)
                {
                    inheritanceBehavior = fce.InheritanceBehavior;
                }
                return(frameworkPropertyMetadata.Inherits);
            }
            return(false);
        }
        // create dependency property entry and set its default and initial inherited value
        private IDependencyPropertyValueEntry CreateDependencyPropertyValueEntry(DependencyProperty dependencyProperty)
        {
            IDependencyPropertyValueEntry entry = new DependencyPropertyValueEntry(this, dependencyProperty);

            PropertyMetadata propertyMetadata = dependencyProperty.GetMetadata(GetType());

            if (propertyMetadata.CoerceValueCallback != null)
            {
                entry = new CoercedDependencyPropertyValueEntry(entry, this, propertyMetadata.CoerceValueCallback);
            }

            entry.SetBaseValue((int)BaseValueSource.Default, propertyMetadata.DefaultValue);
            entry.ValueChanged += (sender, e) => RaisePropertyChanged(new DependencyPropertyChangedEventArgs(dependencyProperty, e.OldValue, e.NewValue));

            return(entry);
        }
Beispiel #11
0
        public DependencyPropertyValueEntry(DependencyObject dependencyObject, DependencyProperty dependencyProperty)
        {
            this.dependencyProperty = dependencyProperty;
            this.defaultValue       = dependencyProperty.GetMetadata(dependencyObject.GetType()).DefaultValue;

            observableValue = new ObservableValue();
            observableValue.ValueChanged += (sender, e) => ValueChanged.Raise(this, e);

            baseValues = new object[BaseValuePriorities];

            for (int i = 0; i < baseValues.Length; i++)
            {
                baseValues[i] = ObservableValue.UnsetValue;
            }

            currentValue   = ObservableValue.UnsetValue;
            animationValue = ObservableValue.UnsetValue;
        }
        public ValueSource GetValueSource(DependencyProperty dependencyProperty)
        {
            IDependencyPropertyValueEntry entry;

            if (entries.TryGetValue(dependencyProperty, out entry))
            {
                return(new ValueSource(
                           (BaseValueSource)entry.GetBaseValuePriority(),
                           entry.GetBaseValue(false) is IExpression || entry.GetCurrentValue(false) is IExpression,
                           entry.GetCurrentValue(true) != ObservableValue.UnsetValue,
                           entry.GetAnimationValue(true) != ObservableValue.UnsetValue,
                           (entry is CoercedDependencyPropertyValueEntry) && ((CoercedDependencyPropertyValueEntry)entry).IsCoerced));
            }

            PropertyMetadata propertyMetadata = dependencyProperty.GetMetadata(GetType());
            BaseValueSource  baseValueSource  = propertyMetadata.Inherits && inheritanceParent != null ? BaseValueSource.Inherited : BaseValueSource.Default;

            return(new ValueSource(baseValueSource, false, false, false, false));
        }
        public AttachedBinding(DependencyObject target, FrameworkElement attachTarget,
            DependencyProperty bindingProperty, Type bindingType)
        {
            // basic checks
            if (target == null) throw new ArgumentNullException("target");
            if (attachTarget == null) throw new ArgumentNullException("attachTarget");
            if (bindingProperty == null) throw new ArgumentNullException("bindingProperty");
            if (bindingType == null) throw new ArgumentNullException("bindingType");

            // we save the reference to the source
            _target = new WeakReference(target);
            _attachTarget = new WeakReference(attachTarget);
            _bindingProperty = bindingProperty;

            // we get the default value
            object _defValue = bindingProperty.GetMetadata(bindingType).DefaultValue;

            // we attach the dp
            if (attachTarget != null)
            {
                // we create the attached property
                _attachedProperty = DependencyProperty.RegisterAttached(string.Format(DP_NAME_FROMAT, _indexer++),
                                                                        bindingType, attachTarget.GetType(),
                                                                        new PropertyMetadata(_defValue,
                                                                                             OnPropertyChanged));
            }
            else
            {
                attachTarget.Loaded += (s, e) =>
                                           {
                                               // we create the binding property
                                               _attachedProperty =
                                                   DependencyProperty.RegisterAttached(
                                                       string.Format(DP_NAME_FROMAT, _indexer++),
                                                       bindingType, attachTarget.GetType(),
                                                       new PropertyMetadata(_defValue, OnPropertyChanged));

                                               // and we if have binding then
                                               if (_binding != null) SetBinding(_binding);
                                           };
            }
        }
Beispiel #14
0
        public object GetValue(DependencyProperty dependencyProperty)
        {
            IDependencyPropertyValueEntry entry;

            if (!entries.TryGetValue(dependencyProperty, out entry))
            {
                PropertyMetadata propertyMetadata = dependencyProperty.GetMetadata(GetType());

                // no need to create a new entry if the value is not inherited or coerced
                if (!propertyMetadata.Inherits && (propertyMetadata.CoerceValueCallback == null || !dependencyProperty.IsAttached && !dependencyProperty.IsContainedBy(GetType())))
                {
                    return(propertyMetadata.DefaultValue);
                }

                entry = CreateDependencyPropertyValueEntry(dependencyProperty, propertyMetadata);
                entries.Add(dependencyProperty, entry);
            }

            return(entry.Value);
        }
Beispiel #15
0
        public void SetValue(DependencyProperty property, object value)
        {
            PropertyMetadata metadata = property.GetMetadata(GetType());

            if (metadata != null)
            {
                if (metadata.ReadOnly)
                {
                    throw new InvalidOperationException(string.Format("DependencyProperty '{0}' has been declared read-only",
                                                                      property.Name));
                }

                if (metadata.SetValueOverride != null)
                {
                    metadata.SetValueOverride(this, value);
                    return;
                }
            }

            SetValueCommon(property, metadata, value);
        }
Beispiel #16
0
        // Token: 0x06000C6F RID: 3183 RVA: 0x0002ED04 File Offset: 0x0002CF04
        internal static bool IsInheritanceNode(DependencyObject d, DependencyProperty dp, out InheritanceBehavior inheritanceBehavior)
        {
            inheritanceBehavior = InheritanceBehavior.Default;
            FrameworkPropertyMetadata frameworkPropertyMetadata = dp.GetMetadata(d.DependencyObjectType) as FrameworkPropertyMetadata;

            if (frameworkPropertyMetadata != null)
            {
                FrameworkObject frameworkObject = new FrameworkObject(d);
                if (!frameworkObject.IsValid)
                {
                    return(false);
                }
                if (frameworkObject.InheritanceBehavior != InheritanceBehavior.Default && !frameworkPropertyMetadata.OverridesInheritanceBehavior)
                {
                    inheritanceBehavior = frameworkObject.InheritanceBehavior;
                }
                if (frameworkPropertyMetadata.Inherits)
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #17
0
        // Token: 0x06000C6D RID: 3181 RVA: 0x0002EB78 File Offset: 0x0002CD78
        private static bool OnInheritablePropertyChanged(DependencyObject d, InheritablePropertyChangeInfo info, bool visitedViaVisualTree)
        {
            DependencyProperty  property = info.Property;
            EffectiveValueEntry oldEntry = info.OldEntry;
            EffectiveValueEntry newEntry = info.NewEntry;
            InheritanceBehavior inheritanceBehavior;
            bool flag  = TreeWalkHelper.IsInheritanceNode(d, property, out inheritanceBehavior);
            bool flag2 = TreeWalkHelper.IsForceInheritedProperty(property);

            if (!flag || (TreeWalkHelper.SkipNext(inheritanceBehavior) && !flag2))
            {
                return(inheritanceBehavior == InheritanceBehavior.Default || flag2);
            }
            PropertyMetadata metadata   = property.GetMetadata(d);
            EntryIndex       entryIndex = d.LookupEntry(property.GlobalIndex);

            if (!d.IsSelfInheritanceParent)
            {
                DependencyObject    frameworkParent      = FrameworkElement.GetFrameworkParent(d);
                InheritanceBehavior inheritanceBehavior2 = InheritanceBehavior.Default;
                if (frameworkParent != null)
                {
                    FrameworkObject frameworkObject = new FrameworkObject(frameworkParent, true);
                    inheritanceBehavior2 = frameworkObject.InheritanceBehavior;
                }
                if (!TreeWalkHelper.SkipNext(inheritanceBehavior) && !TreeWalkHelper.SkipNow(inheritanceBehavior2))
                {
                    d.SynchronizeInheritanceParent(frameworkParent);
                }
                if (oldEntry.BaseValueSourceInternal == BaseValueSourceInternal.Unknown)
                {
                    oldEntry = EffectiveValueEntry.CreateDefaultValueEntry(property, metadata.GetDefaultValue(d, property));
                }
            }
            else
            {
                oldEntry = d.GetValueEntry(entryIndex, property, metadata, RequestFlags.RawEntry);
            }
            if (BaseValueSourceInternal.Inherited >= oldEntry.BaseValueSourceInternal)
            {
                if (visitedViaVisualTree && FrameworkElement.DType.IsInstanceOfType(d))
                {
                    DependencyObject parent = LogicalTreeHelper.GetParent(d);
                    if (parent != null)
                    {
                        DependencyObject parent2 = VisualTreeHelper.GetParent(d);
                        if (parent2 != null && parent2 != parent)
                        {
                            return(false);
                        }
                    }
                }
                return((d.UpdateEffectiveValue(entryIndex, property, metadata, oldEntry, ref newEntry, false, false, OperationType.Inherit) & (UpdateResult)5) == UpdateResult.ValueChanged);
            }
            if (flag2)
            {
                newEntry = new EffectiveValueEntry(property, FullValueSource.IsCoerced);
                return((d.UpdateEffectiveValue(d.LookupEntry(property.GlobalIndex), property, metadata, oldEntry, ref newEntry, false, false, OperationType.Inherit) & (UpdateResult)5) == UpdateResult.ValueChanged);
            }
            return(false);
        }
 internal static void ApplyStyleOrTemplateValue(
         FrameworkObject fo,
         DependencyProperty dp)
 {
     EffectiveValueEntry newEntry = new EffectiveValueEntry(dp);
     newEntry.Value = DependencyProperty.UnsetValue;
     if (GetValueFromStyleOrTemplate(fo, dp, ref newEntry))
     {
         DependencyObject target = fo.DO;
         target.UpdateEffectiveValue(
               target.LookupEntry(dp.GlobalIndex),
               dp,
               dp.GetMetadata(target.DependencyObjectType),
               new EffectiveValueEntry() /* oldEntry */,
               ref newEntry,
               false /* coerceWithDeferredReference */,
               false /* coerceWithCurrentValue */,
               OperationType.Unknown);
     }
 }
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        // Create a new BindingExpression from the given Bind description
        internal static BindingExpression CreateBindingExpression(DependencyObject d,
                                                DependencyProperty dp,
                                                Binding binding,
                                                BindingExpressionBase parent)
        {
            FrameworkPropertyMetadata fwMetaData = dp.GetMetadata(d.DependencyObjectType) as FrameworkPropertyMetadata;

            if ((fwMetaData != null && !fwMetaData.IsDataBindingAllowed) || dp.ReadOnly)
                throw new ArgumentException(SR.Get(SRID.PropertyNotBindable, dp.Name), "dp");

            // create the BindingExpression
            BindingExpression bindExpr = new BindingExpression(binding, parent);

            bindExpr.ResolvePropertyDefaultSettings(binding.Mode, binding.UpdateSourceTrigger, fwMetaData);

            // Two-way Binding with an empty path makes no sense
            if (bindExpr.IsReflective && binding.XPath == null &&
                    (binding.Path == null || String.IsNullOrEmpty(binding.Path.Path)))
                throw new InvalidOperationException(SR.Get(SRID.TwoWayBindingNeedsPath));

            return bindExpr;
        }
        //
        //  This method
        //  1. Is a wrapper for property engine's GetExpression method
        //
        internal static Expression GetExpression(
            DependencyObject d,
            DependencyProperty dp)
        {
            FrameworkElement fe;
            FrameworkContentElement fce;
            Helper.DowncastToFEorFCE(d, out fe, out fce, false);

            // temporarily mark the element as "initialized", so that we always get
            // the desired expression (see GetInstanceValue).
            bool isInitialized = (fe != null) ? fe.IsInitialized : (fce != null) ? fce.IsInitialized : true;
            if (!isInitialized)
            {
                if (fe != null)
                    fe.WriteInternalFlag(InternalFlags.IsInitialized, true);
                else if (fce != null)
                    fce.WriteInternalFlag(InternalFlags.IsInitialized, true);
            }

            // get the desired expression
            Expression result = _getExpression(d, dp, dp.GetMetadata(d.DependencyObjectType));

            // restore the initialized flag
            if (!isInitialized)
            {
                if (fe != null)
                    fe.WriteInternalFlag(InternalFlags.IsInitialized, false);
                else if (fce != null)
                    fce.WriteInternalFlag(InternalFlags.IsInitialized, false);
            }

            return result;
        }
Beispiel #21
0
        /// <summary> 
        ///     Invalidates a property
        /// </summary>
        /// <param name="dp">Dependency property</param>
        //[CodeAnalysis("AptcaMethodsShouldOnlyCallAptcaMethods")] //Tracking Bug: 29647 
        public void InvalidateProperty(DependencyProperty dp)
        { 
            // Do not allow foreign threads access. 
            // (This is a noop if this object is not assigned to a Dispatcher.)
            // 
            this.VerifyAccess();

            if (dp == null)
            { 
                throw new ArgumentNullException("dp");
            } 
 
            EffectiveValueEntry newEntry = new EffectiveValueEntry(dp, BaseValueSourceInternal.Unknown);
 
            UpdateEffectiveValue(
                    LookupEntry(dp.GlobalIndex),
                    dp,
                    dp.GetMetadata(DependencyObjectType), 
                    new EffectiveValueEntry() /* oldEntry */,
                    ref newEntry, 
                    false /* coerceWithDeferredReference */, 
                    false /* coerceWithControlReference */,
                    OperationType.Unknown); 
        }
Beispiel #22
0
        /// <summary>
        ///     Coerce a property value 
        /// </summary> 
        /// <param name="dp">Dependency property</param>
        public void CoerceValue(DependencyProperty dp) 
        {
            // Do not allow foreign threads access.
            // (This is a noop if this object is not assigned to a Dispatcher.)
            // 
            this.VerifyAccess();
 
            EntryIndex entryIndex = LookupEntry(dp.GlobalIndex); 
            PropertyMetadata metadata = dp.GetMetadata(DependencyObjectType);
 
            // if the property has a coerced-with-control value, apply the coercion
            // to that value.  This is done by simply calling SetCurrentValue.
            if (entryIndex.Found)
            { 
                EffectiveValueEntry entry = GetValueEntry(entryIndex, dp, metadata, RequestFlags.RawEntry);
                if (entry.IsCoercedWithCurrentValue) 
                { 
                    SetCurrentValue(dp, entry.ModifiedValue.CoercedValue);
                    return; 
                }
            }

            // IsCoerced == true && value == UnsetValue indicates that we need to re-coerce this value 
            EffectiveValueEntry newEntry = new EffectiveValueEntry(dp, FullValueSource.IsCoerced);
 
            UpdateEffectiveValue( 
                    entryIndex,
                    dp, 
                    metadata,
                    new EffectiveValueEntry() /* oldEntry */,
                    ref newEntry,
                    false /* coerceWithDeferredReference */, 
                    false /* coerceWithCurrentValue */,
                    OperationType.Unknown); 
        } 
Beispiel #23
0
        /// <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;
        } 
Beispiel #24
0
        /// <summary> 
        ///     Determine if the current DependencyObject is a candidate for 
        ///     producing inheritable values
        /// </summary> 
        /// <remarks>
        ///     This is called by both InvalidateTree and GetValueCore
        /// </remarks>
        internal static bool IsInheritanceNode( 
            DependencyObject    d,
            DependencyProperty  dp, 
        out InheritanceBehavior inheritanceBehavior) 
        {
            // Assume can continue search 
            inheritanceBehavior = InheritanceBehavior.Default;

            // Get Framework metadata (if exists)
            FrameworkPropertyMetadata metadata = dp.GetMetadata(d.DependencyObjectType) as FrameworkPropertyMetadata; 

            // Check for correct type of metadata 
            if (metadata != null) 
            {
                FrameworkObject fo = new FrameworkObject(d); 

                if (fo.IsValid)
                {
                    // If parent is a Framework type, then check if it is at a 
                    // tree separation boundary. Stop inheritance at the boundary unless
                    // overridden by the medata.OverridesInheritanceBehavior flag. 
 
                    // GetValue from Parent only if instance is not a TreeSeparator
                    // or fmetadata.OverridesInheritanceBehavior is set to override separated tree behavior 
                    if (fo.InheritanceBehavior != InheritanceBehavior.Default && !metadata.OverridesInheritanceBehavior)
                    {
                        // Hit a tree boundary
                        inheritanceBehavior = fo.InheritanceBehavior; 
                    }
                } 
                else 
                {
                    // If not a Framework type, then, this isn't an inheritance node. 
                    // Only Framework types know how to inherit

                    return false;
                } 

                // Check if metadata is marked as inheritable 
                if (metadata.Inherits) 
                {
                    return true; 
                }
            }

            // Not a framework type with inheritable metadata 
            return false;
        } 
Beispiel #25
0
        void InitializeFeaturePage(Grid grid, DependencyProperty chooserProperty, TypographyFeaturePage page)
        {
            if (page == null)
            {
                grid.Children.Clear();
                grid.RowDefinitions.Clear();
            }
            else
            {
                // Get the property value and metadata.
                object value = GetValue(chooserProperty);
                var metadata = (TypographicPropertyMetadata)chooserProperty.GetMetadata(typeof(FontChooser));

                // Look up the sample text.
                string sampleText = (metadata.SampleTextTag != null) ? LookupString(metadata.SampleTextTag) :
                                    _defaultSampleText;

                if (page == _currentFeaturePage)
                {
                    // Update the state of the controls.
                    for (int i = 0; i < page.Items.Length; ++i)
                    {
                        // Check the radio button if it matches the current property value.
                        if (page.Items[i].Value.Equals(value))
                        {
                            var radioButton = (RadioButton)grid.Children[i * 2];
                            radioButton.IsChecked = true;
                        }

                        // Apply properties to the sample text block.
                        var sample = (TextBlock)grid.Children[i * 2 + 1];
                        sample.Text = sampleText;
                        ApplyPropertiesToObjectExcept(sample, chooserProperty);
                        sample.SetValue(metadata.TargetProperty, page.Items[i].Value);
                    }
                }
                else
                {
                    grid.Children.Clear();
                    grid.RowDefinitions.Clear();

                    // Add row definitions.
                    for (int i = 0; i < page.Items.Length; ++i)
                    {
                        var row = new RowDefinition();
                        row.Height = GridLength.Auto;
                        grid.RowDefinitions.Add(row);
                    }

                    // Add the controls.
                    for (int i = 0; i < page.Items.Length; ++i)
                    {
                        string tag = page.Items[i].Tag;
                        var radioContent = new TextBlock(new Run(LookupString(tag)));
                        radioContent.TextWrapping = TextWrapping.Wrap;

                        // Add the radio button.
                        var radioButton = new RadioButton();
                        radioButton.Name = tag;
                        radioButton.Content = radioContent;
                        radioButton.Margin = new Thickness(5.0, 0.0, 0.0, 0.0);
                        radioButton.VerticalAlignment = VerticalAlignment.Center;
                        Grid.SetRow(radioButton, i);
                        grid.Children.Add(radioButton);

                        // Check the radio button if it matches the current property value.
                        if (page.Items[i].Value.Equals(value))
                        {
                            radioButton.IsChecked = true;
                        }

                        // Hook up the event.
						radioButton.Checked += featureRadioButton_Checked;

                        // Add the block with sample text.
                        var sample = new TextBlock(new Run(sampleText));
                        sample.Margin = new Thickness(5.0, 5.0, 5.0, 0.0);
                        sample.TextWrapping = TextWrapping.WrapWithOverflow;
                        ApplyPropertiesToObjectExcept(sample, chooserProperty);
                        sample.SetValue(metadata.TargetProperty, page.Items[i].Value);
                        Grid.SetRow(sample, i);
                        Grid.SetColumn(sample, 1);
                        grid.Children.Add(sample);
                    }

                    // Add borders between rows.
                    for (int i = 0; i < page.Items.Length; ++i)
                    {
                        var border = new Border();
                        border.BorderThickness = new Thickness(0.0, 0.0, 0.0, 1.0);
                        border.BorderBrush = SystemColors.ControlLightBrush;
                        Grid.SetRow(border, i);
                        Grid.SetColumnSpan(border, 2);
                        grid.Children.Add(border);
                    }
                }
            }

            _currentFeature = chooserProperty;
            _currentFeaturePage = page;
        }
Beispiel #26
0
        // Token: 0x06000C59 RID: 3161 RVA: 0x0002DFDC File Offset: 0x0002C1DC
        internal FrugalObjectList <DependencyProperty> CreateParentInheritableProperties(DependencyObject d, DependencyObject parent, bool isAddOperation)
        {
            if (parent == null)
            {
                return(new FrugalObjectList <DependencyProperty>(0));
            }
            DependencyObjectType dependencyObjectType = d.DependencyObjectType;

            EffectiveValueEntry[] array = null;
            uint num  = 0U;
            uint num2 = 0U;

            if (!parent.IsSelfInheritanceParent)
            {
                DependencyObject inheritanceParent = parent.InheritanceParent;
                if (inheritanceParent != null)
                {
                    array = inheritanceParent.EffectiveValues;
                    num   = inheritanceParent.EffectiveValuesCount;
                    num2  = inheritanceParent.InheritableEffectiveValuesCount;
                }
            }
            else
            {
                array = parent.EffectiveValues;
                num   = parent.EffectiveValuesCount;
                num2  = parent.InheritableEffectiveValuesCount;
            }
            FrugalObjectList <DependencyProperty> frugalObjectList = new FrugalObjectList <DependencyProperty>((int)num2);

            if (num2 == 0U)
            {
                return(frugalObjectList);
            }
            this._rootInheritableValues = new InheritablePropertyChangeInfo[num2];
            int             num3            = 0;
            FrameworkObject frameworkObject = new FrameworkObject(parent);

            for (uint num4 = 0U; num4 < num; num4 += 1U)
            {
                EffectiveValueEntry effectiveValueEntry = array[(int)num4];
                DependencyProperty  dependencyProperty  = DependencyProperty.RegisteredPropertyList.List[effectiveValueEntry.PropertyIndex];
                if (dependencyProperty != null && dependencyProperty.IsPotentiallyInherited)
                {
                    PropertyMetadata metadata = dependencyProperty.GetMetadata(parent.DependencyObjectType);
                    if (metadata != null && metadata.IsInherited)
                    {
                        FrameworkPropertyMetadata frameworkPropertyMetadata = (FrameworkPropertyMetadata)metadata;
                        if (!TreeWalkHelper.SkipNow(frameworkObject.InheritanceBehavior) || frameworkPropertyMetadata.OverridesInheritanceBehavior)
                        {
                            frugalObjectList.Add(dependencyProperty);
                            EffectiveValueEntry valueEntry = d.GetValueEntry(d.LookupEntry(dependencyProperty.GlobalIndex), dependencyProperty, dependencyProperty.GetMetadata(dependencyObjectType), RequestFlags.DeferredReferences);
                            EffectiveValueEntry newEntry;
                            if (isAddOperation)
                            {
                                newEntry = effectiveValueEntry;
                                if (newEntry.BaseValueSourceInternal != BaseValueSourceInternal.Default || newEntry.HasModifiers)
                                {
                                    newEntry = newEntry.GetFlattenedEntry(RequestFlags.FullyResolved);
                                    newEntry.BaseValueSourceInternal = BaseValueSourceInternal.Inherited;
                                }
                            }
                            else
                            {
                                newEntry = default(EffectiveValueEntry);
                            }
                            this._rootInheritableValues[num3++] = new InheritablePropertyChangeInfo(d, dependencyProperty, valueEntry, newEntry);
                            if ((ulong)num2 == (ulong)((long)num3))
                            {
                                break;
                            }
                        }
                    }
                }
            }
            return(frugalObjectList);
        }
        /// <summary>
        ///     Called by SetValue or ClearValue to verify that the property
        /// can be changed.
        /// </summary>
        private PropertyMetadata SetupPropertyChange(DependencyPropertyKey key, out DependencyProperty dp)
        {
            if ( key != null )
            {
                dp = key.DependencyProperty;
                Debug.Assert(dp != null);

                dp.VerifyReadOnlyKey(key);

                // Get type-specific metadata for this property
                return dp.GetMetadata(DependencyObjectType);
            }
            else
            {
                throw new ArgumentNullException("key");
            }
        }
Beispiel #28
0
        public void SetValueBase(DependencyProperty property, object value)
        {
            PropertyMetadata metadata = property.GetMetadata(GetType());

            SetValueCommon(property, metadata, value);
        }
Beispiel #29
0
        [FriendAccessAllowed] // Built into Base, also used by Core & Framework.
        internal BaseValueSourceInternal GetValueSource(DependencyProperty dp, PropertyMetadata metadata, 
                out bool hasModifiers, out bool isExpression, out bool isAnimated, out bool isCoerced, out bool isCurrent) 
        {
            if (dp == null) 
            {
                throw new ArgumentNullException("dp");
            }
 
            EntryIndex entryIndex = LookupEntry(dp.GlobalIndex);
 
            if (entryIndex.Found) 
            {
                EffectiveValueEntry entry = _effectiveValues[entryIndex.Index]; 
                hasModifiers = entry.HasModifiers;
                isExpression = entry.IsExpression;
                isAnimated = entry.IsAnimated;
                isCoerced = entry.IsCoerced; 
                isCurrent = entry.IsCoercedWithCurrentValue;
                return entry.BaseValueSourceInternal; 
            } 
            else
            { 
                isExpression = false;
                isAnimated = false;
                isCoerced = false;
                isCurrent = false; 

                if (dp.ReadOnly) 
                { 
                    if (metadata == null)
                    { 
                        metadata = dp.GetMetadata(DependencyObjectType);
                    }

                    GetReadOnlyValueCallback callback = metadata.GetReadOnlyValueCallback; 
                    if (callback != null)
                    { 
                        BaseValueSourceInternal source; 
                        callback(this, out source);
                        hasModifiers = false; 
                        return source;
                    }
                }
 
                if (dp.IsPotentiallyInherited)
                { 
                    if (metadata == null) 
                    {
                        metadata = dp.GetMetadata(DependencyObjectType); 
                    }

                    if (metadata.IsInherited)
                    { 
                        DependencyObject inheritanceParent = InheritanceParent;
                        if (inheritanceParent != null && inheritanceParent.LookupEntry(dp.GlobalIndex).Found) 
                        { 
                            hasModifiers = false;
                            return BaseValueSourceInternal.Inherited; 
                        }
                    }
                }
            } 

            hasModifiers = false; 
            return BaseValueSourceInternal.Default; 
        }
        internal static void ApplyTemplatedParentValue(
                DependencyObject                container,
                FrameworkObject                 child,
                int                             childIndex,
            ref FrugalStructList<ChildRecord>   childRecordFromChildIndex,
                DependencyProperty              dp,
                FrameworkElementFactory         templateRoot)
        {
            EffectiveValueEntry newEntry = new EffectiveValueEntry(dp);
            newEntry.Value = DependencyProperty.UnsetValue;
            if (GetValueFromTemplatedParent(
                    container,
                    childIndex,
                    child,
                    dp,
                ref childRecordFromChildIndex,
                    templateRoot,
                ref newEntry))

            {
                DependencyObject target = child.DO;
                target.UpdateEffectiveValue(
                        target.LookupEntry(dp.GlobalIndex),
                        dp,
                        dp.GetMetadata(target.DependencyObjectType),
                        new EffectiveValueEntry() /* oldEntry */,
                    ref newEntry,
                        false /* coerceWithDeferredReference */,
                        false /* coerceWithCurrentValue */,
                        OperationType.Unknown);
            }
        }
Beispiel #31
0
        /// <summary> 
        ///     Called by SetValue or ClearValue to verify that the property
        /// can be changed. 
        /// </summary> 
        private PropertyMetadata SetupPropertyChange(DependencyPropertyKey key, out DependencyProperty dp)
        { 
            if ( key != null )
            {
                dp = key.DependencyProperty;
 
                if ( dp != null )
                { 
                    dp.VerifyReadOnlyKey(key); 

                    // Get type-specific metadata for this property 
                    return dp.GetMetadata(DependencyObjectType);
                }
                else
                { 
                    throw new ArgumentException(SR.Get(SRID.ReadOnlyKeyNotAuthorized, dp.Name));
                } 
            } 
            else
            { 
                throw new ArgumentNullException("key");
            }
        }
 static object GetDefaultValue(DependencyProperty dp)
 {
     return dp.GetMetadata(typeof(SmoothStreamingMediaElement)).DefaultValue;
 }
Beispiel #33
0
        //+----------------------------------------------------------------------------------------------------------------------- 
        //
        //  SetDependencyValue 
        // 
        //  We call this routine to set a DP value onto a DO, but it's virtual so that custom baml record readers
        //  can do their own thing.  This was added so that templates could set unshareable template child property 
        //  values into per-FE state.
        //
        //+-----------------------------------------------------------------------------------------------------------------------
 
        internal void SetDependencyValue(DependencyObject dependencyObject, DependencyProperty dependencyProperty, object value)
        { 
            // We don't need to get the metadata if we aren't skipping journaled properties 
            FrameworkPropertyMetadata metadata = ParserContext != null && ParserContext.SkipJournaledProperties ?
                dependencyProperty.GetMetadata(dependencyObject.DependencyObjectType) as FrameworkPropertyMetadata 
                : null;

            // If the metadata is not null here, we are skipping journaled properties (if the metadata requires it)
            // NOTE: we do not journal expression. So even when the property is journalable but the value is expression, 
            // we still want to set the value from parser. See corresponding code for avoiding saving expression in DataStream.SaveSubStreams.
            // Please see Windows OS bug # 1852349 for details. 
            if ((metadata == null) || (!metadata.Journal) || (value is Expression)) 
            {
                SetDependencyValueCore(dependencyObject, dependencyProperty, value); 
            }
        }
Beispiel #34
0
 [FriendAccessAllowed] // Built into Base, also used by Framework.
 internal void InvalidateSubProperty(DependencyProperty dp) 
 {
     // when a sub property changes, send a Changed notification with old and new value being the same, and with 
     // IsASubPropertyChange set to true 
     NotifyPropertyChange(new DependencyPropertyChangedEventArgs(dp, dp.GetMetadata(DependencyObjectType), GetValue(dp)));
 } 
        //
        //  This method
        //  1. Is called from AncestorChange InvalidateTree.
        //  2. It is used to create the InheritableProperties on the given node.
        //  3. It also accumulates oldValues for the inheritable properties that are about to be invalidated
        //
        internal FrugalObjectList <DependencyProperty> CreateParentInheritableProperties(
            DependencyObject d,
            DependencyObject parent,
            bool isAddOperation)
        {
            Debug.Assert(d != null, "Must have non-null current node");

            if (parent == null)
            {
                return(new FrugalObjectList <DependencyProperty>(0));
            }

            DependencyObjectType treeObjDOT = d.DependencyObjectType;

            // See if we have a cached value.
            EffectiveValueEntry[] parentEffectiveValues = null;
            uint parentEffectiveValuesCount             = 0;
            uint inheritablePropertiesCount             = 0;

            // If inheritable properties aren't cached on you then use the effective
            // values cache on the parent to discover those inherited properties that
            // may need to be invalidated on the children nodes.
            if (!parent.IsSelfInheritanceParent)
            {
                DependencyObject inheritanceParent = parent.InheritanceParent;
                if (inheritanceParent != null)
                {
                    parentEffectiveValues      = inheritanceParent.EffectiveValues;
                    parentEffectiveValuesCount = inheritanceParent.EffectiveValuesCount;
                    inheritablePropertiesCount = inheritanceParent.InheritableEffectiveValuesCount;
                }
            }
            else
            {
                parentEffectiveValues      = parent.EffectiveValues;
                parentEffectiveValuesCount = parent.EffectiveValuesCount;
                inheritablePropertiesCount = parent.InheritableEffectiveValuesCount;
            }

            FrugalObjectList <DependencyProperty> inheritableProperties = new FrugalObjectList <DependencyProperty>((int)inheritablePropertiesCount);

            if (inheritablePropertiesCount == 0)
            {
                return(inheritableProperties);
            }

            _rootInheritableValues = new InheritablePropertyChangeInfo[(int)inheritablePropertiesCount];
            int inheritableIndex = 0;

            FrameworkObject foParent = new FrameworkObject(parent);

            for (uint i = 0; i < parentEffectiveValuesCount; i++)
            {
                // Add all the inheritable properties from the effectiveValues
                // cache to the TreeStateCache on the parent
                EffectiveValueEntry entry = parentEffectiveValues[i];
                DependencyProperty  dp    = DependencyProperty.RegisteredPropertyList.List[entry.PropertyIndex];

                // There are UncommonFields also stored in the EffectiveValues cache. We need to exclude those.
                if ((dp != null) && dp.IsPotentiallyInherited)
                {
                    PropertyMetadata metadata = dp.GetMetadata(parent.DependencyObjectType);
                    if (metadata != null && metadata.IsInherited)
                    {
                        Debug.Assert(!inheritableProperties.Contains(dp), "EffectiveValues cache must not contains duplicate entries for the same DP");

                        FrameworkPropertyMetadata fMetadata = (FrameworkPropertyMetadata)metadata;

                        // Children do not need to inherit properties across a tree boundary
                        // unless the property is set to override this behavior.

                        if (!TreeWalkHelper.SkipNow(foParent.InheritanceBehavior) || fMetadata.OverridesInheritanceBehavior)
                        {
                            inheritableProperties.Add(dp);

                            EffectiveValueEntry oldEntry;
                            EffectiveValueEntry newEntry;

                            oldEntry = d.GetValueEntry(
                                d.LookupEntry(dp.GlobalIndex),
                                dp,
                                dp.GetMetadata(treeObjDOT),
                                RequestFlags.DeferredReferences);

                            if (isAddOperation)
                            {
                                // set up the new value
                                newEntry = entry;

                                if ((newEntry.BaseValueSourceInternal != BaseValueSourceInternal.Default) || newEntry.HasModifiers)
                                {
                                    newEntry = newEntry.GetFlattenedEntry(RequestFlags.FullyResolved);
                                    newEntry.BaseValueSourceInternal = BaseValueSourceInternal.Inherited;
                                }
                            }
                            else
                            {
                                newEntry = new EffectiveValueEntry();
                            }


                            _rootInheritableValues[inheritableIndex++] =
                                new InheritablePropertyChangeInfo(d, dp, oldEntry, newEntry);

                            if (inheritablePropertiesCount == inheritableIndex)
                            {
                                // no more inheritable properties, bail early
                                break;
                            }
                        }
                    }
                }
            }

            return(inheritableProperties);
        }
Beispiel #36
0
        [FriendAccessAllowed] // Built into Base, also used by Core.
        internal EffectiveValueEntry GetValueEntry( 
            EntryIndex          entryIndex,
            DependencyProperty  dp,
            PropertyMetadata    metadata,
            RequestFlags        requests) 
        {
            EffectiveValueEntry entry; 
 
            if (dp.ReadOnly)
            { 
                if (metadata == null)
                {
                    metadata = dp.GetMetadata(DependencyObjectType);
                } 

                GetReadOnlyValueCallback getValueCallback = metadata.GetReadOnlyValueCallback; 
                if (getValueCallback != null) 
                {
                    BaseValueSourceInternal valueSource; 
                    entry = new EffectiveValueEntry(dp);
                    entry.Value = getValueCallback(this, out valueSource);
                    entry.BaseValueSourceInternal = valueSource;
                    return entry; 
                }
            } 
 
            if (entryIndex.Found)
            { 
                if ((requests & RequestFlags.RawEntry) != 0)
                {
                    entry = _effectiveValues[entryIndex.Index];
                } 
                else
                { 
                    entry = GetEffectiveValue( 
                                entryIndex,
                                dp, 
                                requests);
                }
            }
            else 
            {
                entry = new EffectiveValueEntry(dp, BaseValueSourceInternal.Unknown); 
            } 

            if (entry.Value == DependencyProperty.UnsetValue) 
            {
                if (dp.IsPotentiallyInherited)
                {
                    if (metadata == null) 
                    {
                        metadata = dp.GetMetadata(DependencyObjectType); 
                    } 

                    if (metadata.IsInherited) 
                    {
                        DependencyObject inheritanceParent = InheritanceParent;
                        if (inheritanceParent != null)
                        { 
                            entryIndex = inheritanceParent.LookupEntry(dp.GlobalIndex);
 
                            if (entryIndex.Found) 
                            {
                                entry = inheritanceParent.GetEffectiveValue( 
                                                entryIndex,
                                                dp,
                                                requests & RequestFlags.DeferredReferences);
                                entry.BaseValueSourceInternal = BaseValueSourceInternal.Inherited; 
                            }
                        } 
                    } 

                    if (entry.Value != DependencyProperty.UnsetValue) 
                    {
                        return entry;
                    }
                } 

                if ((requests & RequestFlags.SkipDefault) == 0) 
                { 
                    if (dp.IsPotentiallyUsingDefaultValueFactory)
                    { 
                        if (metadata == null)
                        {
                            metadata = dp.GetMetadata(DependencyObjectType);
                        } 

                        if (((requests & (RequestFlags.DeferredReferences | RequestFlags.RawEntry)) != 0) && metadata.UsingDefaultValueFactory) 
                        { 
                            entry.BaseValueSourceInternal = BaseValueSourceInternal.Default;
 
                            entry.Value = new DeferredMutableDefaultReference(metadata, this, dp);
                            return entry;
                        }
                    } 
                    else if (!dp.IsDefaultValueChanged)
                    { 
                        return EffectiveValueEntry.CreateDefaultValueEntry(dp, dp.DefaultMetadata.DefaultValue); 
                    }
 
                    if (metadata == null)
                    {
                        metadata = dp.GetMetadata(DependencyObjectType);
                    } 

                    return EffectiveValueEntry.CreateDefaultValueEntry(dp, metadata.GetDefaultValue(this, dp)); 
                } 
            }
            return entry; 
        }
        public DependencyPropertyValueEntry(DependencyObject dependencyObject, DependencyProperty dependencyProperty)
        {
            this.dependencyProperty = dependencyProperty;
            this.defaultValue = dependencyProperty.GetMetadata(dependencyObject.GetType()).DefaultValue;

            currentValue = new ObservableValue();
            currentValue.ValueChanged += (sender, e) => ValueChanged.Raise(this, e);

            baseValues = new object[BaseValuePriorities];

            for (int i = 0; i < baseValues.Length; i++)
            {
                baseValues[i] = ObservableValue.UnsetValue;
            }

            animationValue = ObservableValue.UnsetValue;
        }
Beispiel #38
0
 /// <summary> 
 ///     Called by SetValue or ClearValue to verify that the property
 /// can be changed. 
 /// </summary>
 private PropertyMetadata SetupPropertyChange(DependencyProperty dp)
 {
     if ( dp != null ) 
     {
         if ( !dp.ReadOnly ) 
         { 
             // Get type-specific metadata for this property
             return dp.GetMetadata(DependencyObjectType); 
         }
         else
         {
             throw new InvalidOperationException(SR.Get(SRID.ReadOnlyChangeNotAllowed, dp.Name)); 
         }
     } 
     else 
     {
         throw new ArgumentNullException("dp"); 
     }
 }
Beispiel #39
0
        // create dependency property entry and set its default and initial inherited value
        private IDependencyPropertyValueEntry CreateDependencyPropertyValueEntry(DependencyProperty dependencyProperty)
        {
            IDependencyPropertyValueEntry entry = new DependencyPropertyValueEntry(this, dependencyProperty);

            PropertyMetadata propertyMetadata = dependencyProperty.GetMetadata(GetType());

            if (propertyMetadata.CoerceValueCallback != null)
            {
                entry = new CoercedDependencyPropertyValueEntry(entry, this, propertyMetadata.CoerceValueCallback);
            }

            entry.SetBaseValue((int)BaseValueSource.Default, propertyMetadata.DefaultValue);
            entry.ValueChanged += (sender, e) => RaisePropertyChanged(new DependencyPropertyChangedEventArgs(dependencyProperty, e.OldValue, e.NewValue));

            return entry;
        }
Beispiel #40
0
 public void InvalidateProperty(DependencyProperty property)
 {
     InvalidateProperty(property, property.GetMetadata(GetType()));
 }
Beispiel #41
0
 public object GetValueBase(DependencyProperty property)
 {
     return(GetValueCommon(property, property.GetMetadata(this.GetType())));
 }
            internal FreezableDefaultPromoter(DependencyObject owner, DependencyProperty property)
            {
                Debug.Assert(owner != null && property != null,
                    "Caller is responsible for ensuring that owner and property are non-null.");
                Debug.Assert(!(owner is Freezable) || !((Freezable)owner).IsFrozen,
                    "We should not be observing mutables on a frozen owner.");
                Debug.Assert(property.GetMetadata(owner.DependencyObjectType).UsingDefaultValueFactory,
                    "How did we end up observing a mutable if we were not registered for the factory pattern?");

                // We hang on to the property and owner so we can write the default
                // value back to the local store if it changes.  See also
                // OnDefaultValueChanged.
                _owner = owner;
                _property = property;
            }
Beispiel #43
0
 public void CoerceValue(DependencyProperty dp)
 {
     PropertyMetadata pm = dp.GetMetadata (this);
     if (pm.CoerceValueCallback != null)
         pm.CoerceValueCallback (this, GetValue (dp));
 }
Beispiel #44
0
        /// <summary>
        ///     FrameworkContentElement variant of IsInheritanceNode 
        /// </summary>
        internal static bool IsInheritanceNode( 
            FrameworkContentElement fce, 
            DependencyProperty      dp,
            out InheritanceBehavior inheritanceBehavior) 
        {
            // Assume can continue search
            inheritanceBehavior = InheritanceBehavior.Default;
 
            // Get Framework metadata (if exists)
            FrameworkPropertyMetadata metadata = dp.GetMetadata(fce.DependencyObjectType) as FrameworkPropertyMetadata; 
 
            // Check for correct type of metadata
            if (metadata != null) 
            {
                if (fce.InheritanceBehavior != InheritanceBehavior.Default && !metadata.OverridesInheritanceBehavior)
                {
                    // Hit a tree boundary 
                    inheritanceBehavior = fce.InheritanceBehavior;
                } 
 
                // Return true if metadata is marked as inheritable; false otherwise
                return metadata.Inherits; 
            }

            // Not framework type metadata
            return false; 
        }
Beispiel #45
0
        public ValueSource GetValueSource(DependencyProperty dependencyProperty)
        {
            IDependencyPropertyValueEntry entry;
            if (entries.TryGetValue(dependencyProperty, out entry))
            {
                return new ValueSource(
                    (BaseValueSource)entry.GetBaseValuePriority(),
                    entry.GetBaseValue(false) is IExpression || entry.GetCurrentValue(false) is IExpression,
                    entry.GetCurrentValue(true) != ObservableValue.UnsetValue,
                    entry.GetAnimationValue(true) != ObservableValue.UnsetValue,
                    (entry is CoercedDependencyPropertyValueEntry) && ((CoercedDependencyPropertyValueEntry)entry).IsCoerced);
            }

            PropertyMetadata propertyMetadata = dependencyProperty.GetMetadata(GetType());
            BaseValueSource baseValueSource = propertyMetadata.Inherits && inheritanceParent != null ? BaseValueSource.Inherited : BaseValueSource.Default;
            return new ValueSource(baseValueSource, false, false, false, false);
        }