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