/// <summary> /// Registers an attached <see cref="AvaloniaProperty"/>. /// </summary> /// <typeparam name="TOwner">The type of the class that is registering the property.</typeparam> /// <typeparam name="THost">The type of the class that the property is to be registered on.</typeparam> /// <typeparam name="TValue">The type of the property's value.</typeparam> /// <param name="name">The name of the property.</param> /// <param name="defaultValue">The default value of the property.</param> /// <param name="inherits">Whether the property inherits its value.</param> /// <param name="defaultBindingMode">The default binding mode for the property.</param> /// <param name="validate">A validation function.</param> /// <returns>A <see cref="AvaloniaProperty{TValue}"/></returns> public static AttachedProperty <TValue> RegisterAttached <TOwner, THost, TValue>( string name, TValue defaultValue = default(TValue), bool inherits = false, BindingMode defaultBindingMode = BindingMode.OneWay, Func <THost, TValue, TValue> validate = null) where THost : IAvaloniaObject { Contract.Requires <ArgumentNullException>(name != null); var metadata = new StyledPropertyMetadata <TValue>( defaultValue, validate: Cast(validate), defaultBindingMode: defaultBindingMode); var result = new AttachedProperty <TValue>(name, typeof(TOwner), metadata, inherits); var registry = AvaloniaPropertyRegistry.Instance; registry.Register(typeof(TOwner), result); registry.RegisterAttached(typeof(THost), result); return(result); }
/// <summary> /// Overrides the metadata for the property on the specified type. /// </summary> /// <typeparam name="T">The type.</typeparam> /// <param name="metadata">The metadata.</param> public void OverrideMetadata <T>(StyledPropertyMetadata <TValue> metadata) where T : IAvaloniaObject { base.OverrideMetadata(typeof(T), metadata); }
/// <summary> /// Overrides the metadata for the property on the specified type. /// </summary> /// <param name="type">The type.</param> /// <param name="metadata">The metadata.</param> public void OverrideMetadata(Type type, StyledPropertyMetadata <TValue> metadata) { base.OverrideMetadata(type, metadata); }