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


C# DependencyProperty.GetMetadata方法代码示例

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


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

示例1: WriteNoninheritableProperty

        // Writes a value of an individual non-inheritable property in form of attribute string.
        // If the value cannot be serialized as a string, adds the property to a collection of complexProperties.
        // To minimize the amount of xaml produced, the property is skipped if its value is equal to its default value
        // for the given element type - the propertyOwnerType.
        // The flag onlyAffected=false means that we want to output all properties independently on
        // if they are equal to their default values or not.
        private static void WriteNoninheritableProperty(XmlWriter xmlWriter, DependencyProperty property, object propertyValue, Type propertyOwnerType, bool onlyAffected, DependencyObject complexProperties, object localValue)
        {
            bool write = false;
            if (propertyValue != null &&
                propertyValue != DependencyProperty.UnsetValue)
            {
                if (!onlyAffected)
                {
                    write = true;
                }
                else
                {
                    PropertyMetadata metadata = property.GetMetadata(propertyOwnerType);

                    write = (metadata == null) || !(TextSchema.ValuesAreEqual(propertyValue, /*defaultValue*/metadata.DefaultValue) && localValue == DependencyProperty.UnsetValue);
                }
            }

            if (write)
            {
                string stringValue = DPTypeDescriptorContext.GetStringValue(property, propertyValue);

                if (stringValue != null)
                {
                    stringValue = FilterNaNStringValueForDoublePropertyType(stringValue, property.PropertyType);

                    // For the property name in this case we safe to use simple name only;
                    // as noninheritable property would never require TypeName.PropertyName notation
                    // for attribute syntax.
                    xmlWriter.WriteAttributeString(property.Name, stringValue);
                }
                else
                {
                    complexProperties.SetValue(property, propertyValue);
                }
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:43,代码来源:TextRangeSerialization.cs

示例2: CreateStorage

        private static AnimationStorage CreateStorage(
             DependencyObject d,
             DependencyProperty dp)
        {
            AnimationStorage newStorage;

            if (dp.GetMetadata(d.DependencyObjectType) is IndependentlyAnimatedPropertyMetadata)
            {
                newStorage = CreateIndependentAnimationStorageForType(dp.PropertyType);
            }
            else
            {
                newStorage = new AnimationStorage();
            }

            newStorage.Initialize(d, dp);

            return newStorage;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:19,代码来源:AnimationStorage.cs

示例3: GetDefaultBindingMode

 private static BindingMode GetDefaultBindingMode(DependencyObject dependencyObject, DependencyProperty dependencyProperty)
 {
     FrameworkPropertyMetadata frameworkPropertyMetadata = dependencyProperty.GetMetadata(dependencyObject.GetType()) as FrameworkPropertyMetadata;
     return frameworkPropertyMetadata != null && frameworkPropertyMetadata.BindsTwoWayByDefault ? BindingMode.TwoWay : BindingMode.OneWay;
 }
开发者ID:highzion,项目名称:Granular,代码行数:5,代码来源:BindingExpression.cs

示例4: IsPropertyAnimatable

        [FriendAccessAllowed] // Built into Core, also used by Framework.
        internal static bool IsPropertyAnimatable(
            DependencyObject d,
            DependencyProperty dp)
        {
            //



            if (dp.PropertyType != typeof(Visual3DCollection) && dp.ReadOnly)
            {
                return false;
            }

            UIPropertyMetadata uiMetadata = dp.GetMetadata(d.DependencyObjectType) as UIPropertyMetadata;

            if (   uiMetadata != null
                && uiMetadata.IsAnimationProhibited)
            {
                return false;
            }

            return true;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:24,代码来源:AnimationStorage.cs

示例5: CoerceValue

        public void CoerceValue(DependencyProperty dp)
        {
            if (dp == null)
                throw new ArgumentNullException("dp");

            PropertyMetadata pm = dp.GetMetadata(this);
            if (pm.CoerceValueCallback != null)
                pm.CoerceValueCallback(this, GetValue(dp));
        }
开发者ID:tfreitasleal,项目名称:MvvmFx,代码行数:9,代码来源:Form.cs

示例6: CreateBindingExpression

    //------------------------------------------------------
    //
    //  Internal Methods
    //
    //------------------------------------------------------

    // Create a new BindingExpression from the given Binding description
    internal static PriorityBindingExpression CreateBindingExpression(DependencyObject d, DependencyProperty dp, PriorityBinding binding, BindingExpressionBase owner)
    {
        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
        PriorityBindingExpression bindExpr = new PriorityBindingExpression(binding, owner);

        return bindExpr;
    }
开发者ID:JianwenSun,项目名称:cc,代码行数:19,代码来源:PriorityBindingExpression.cs

示例7: CreateBindingExpression

    //------------------------------------------------------
    //
    //  Internal Methods
    //
    //------------------------------------------------------

    // Create a new BindingExpression from the given Binding description
    internal static MultiBindingExpression CreateBindingExpression(DependencyObject d, DependencyProperty dp, MultiBinding binding, BindingExpressionBase owner)
    {
        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
        MultiBindingExpression bindExpr = new MultiBindingExpression(binding, owner);

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

        return bindExpr;
    }
开发者ID:JianwenSun,项目名称:cc,代码行数:21,代码来源:MultiBindingExpression.cs

示例8: OnPropertyChanged

 protected override void OnPropertyChanged(DependencyProperty property, object newValue, object oldValue)
 {
     var type = GetType();
     var metadata = property.GetMetadata(type);
     // Handle metadata properties when property value is changed.
     if (metadata.AffectsMeasure)
         InvalidateMeasure();
     if (metadata.AffectsArrange)
         InvalidateArrange();
     if (metadata.AffectsParentArrange)
         Parent?.InvalidateArrange();
     if (metadata.AffectsParentMeasure)
         Parent?.InvalidateMeasure();
 }
开发者ID:Pyratron,项目名称:PyraUI,代码行数:14,代码来源:Element.cs


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