public static RegisterAttached ( string name, Type propertyType, Type ownerType ) : |
||
name | string | |
propertyType | Type | |
ownerType | Type | |
return |
public static void RegisterForNotification([NotNull] this FrameworkElement element, string PropertyName, PropertyChangedCallback callback) { var binding = new Binding(PropertyName) { Source = element }; var prop = DependencyProperty.RegisterAttached($"ListenAttached{PropertyName}", typeof(object), element.GetType(), new PropertyMetadata(callback)); element.SetBinding(prop, binding); }
public static DependencyProperty RegisterListener( string propertyPath, Type type, PropertyChangedCallback callback) { long index = DateTime.Now.Ticks; string typeName = type.Name.Replace('.', '_'); string name = string.Format("Listener{0}{1}{2}", typeName, propertyPath, index); DependencyProperty prop = null; do { try { prop = DependencyProperty.RegisterAttached( name, typeof(object), type, new PropertyMetadata(callback)); break; } catch { index = DateTime.Now.Ticks; name = string.Format("Listener{0}{1}{2}", typeName, propertyPath, index); } }while (true); return(prop); }