Page 1 of 1

What's the equivalent of DependencyPropertyDescriptor.AddValueChanged() ?

Posted: 17 Jan 2021, 04:09
by horeaper
I'm porting a library from WPF to Noesis, which requires other objects to be notified when property changes.

Re: What's the equivalent of DependencyPropertyDescriptor.AddValueChanged() ?

Posted: 18 Jan 2021, 16:33
by sfernandez
I'm sorry DependencyPropertyDescriptor is not implemented yet (#822). But you can use attached properties to add your own PropertyChangedCallback and bind to the desired property to be notified when the source property changes:
public static readonly DependencyProperty ChangeListenerProperty = DependencyProperty.RegisterAttached(
  "ChangeListener", typeof(object), typeof(PropertyHelper),
  new PropertyMetadata(null, OnValueChanged));
  
private void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
  // your code here...
}
someTextBox.SetBinding(PropertyHelper.ChangeListenerProperty, new Binding(TextBox.TextProperty, someTextBox);
Is this something you can use in your project?

Re: What's the equivalent of DependencyPropertyDescriptor.AddValueChanged() ?

Posted: 19 Jan 2021, 04:43
by horeaper
It will do, thanks! 👍