/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <typeparam name="TResult"></typeparam> /// <param name="instance"></param> /// <param name="attachedProperty"></param> /// <param name="context"></param> /// <returns></returns> public static TResult GetAttachedValue <T, TResult>(this T instance, AttachedProperty <T, TResult> attachedProperty, AttachedPropertyContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var value = context.GetInstanceValue(instance, attachedProperty); return(value); }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <typeparam name="TResult"></typeparam> /// <param name="instance"></param> /// <param name="attachedProperty"></param> /// <param name="value"></param> /// <param name="context"></param> public static void SetAttachedValue <T, TResult>(this T instance, AttachedProperty <T, TResult> attachedProperty, TResult value, AttachedPropertyContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } context.SetInstanceValue(instance, attachedProperty, value); }
/// <summary> /// Creates a <see cref="AttachedProperties"/> which is used to attach values to instances /// in a specified context. /// </summary> /// <param name="name"></param> /// <param name="context"></param> public AttachedProperty(string name, AttachedPropertyContext context) : base(typeof(TOwner), typeof(TProperty), name, context) { }