/// <summary>Registers an event callback on a given dependency property. </summary> /// <param name="frameworkElement">The source framework element. </param> /// <param name="property">The property to register the callback for. </param> /// <param name="handler">The event handler. </param> public static void Register(FrameworkElement frameworkElement, DependencyProperty property, Action<object, object> handler) { if (_dependencyPropertyRegistrations == null) _dependencyPropertyRegistrations = new List<DependencyPropertyRegistration>(); var helper = new DependencyPropertyRegistration( frameworkElement, property, handler, frameworkElement.GetValue(property)); var binding = new Binding(); binding.Path = new PropertyPath("Property"); binding.Source = helper; binding.Mode = BindingMode.TwoWay; frameworkElement.SetBinding(property, binding); _dependencyPropertyRegistrations.Add(helper); }
/// <summary>Registers an event callback on a given dependency property. </summary> /// <param name="frameworkElement">The source framework element. </param> /// <param name="property">The property to register the callback for. </param> /// <param name="handler">The event handler. </param> public static void Register(FrameworkElement frameworkElement, DependencyProperty property, Action <object, object> handler) { if (_dependencyPropertyRegistrations == null) { _dependencyPropertyRegistrations = new List <DependencyPropertyRegistration>(); } var helper = new DependencyPropertyRegistration( frameworkElement, property, handler, frameworkElement.GetValue(property)); var binding = new Binding(); binding.Path = new PropertyPath("Property"); binding.Source = helper; binding.Mode = BindingMode.TwoWay; frameworkElement.SetBinding(property, binding); _dependencyPropertyRegistrations.Add(helper); }