User avatar
horeaper
Topic Author
Posts: 34
Joined: 22 Sep 2014, 12:50

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

17 Jan 2021, 04:09

I'm porting a library from WPF to Noesis, which requires other objects to be notified when property changes.
 
User avatar
sfernandez
Site Admin
Posts: 2254
Joined: 22 Dec 2011, 19:20

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

18 Jan 2021, 16:33

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?
 
User avatar
horeaper
Topic Author
Posts: 34
Joined: 22 Sep 2014, 12:50

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

19 Jan 2021, 04:43

It will do, thanks! 👍

Who is online

Users browsing this forum: Google [Bot], sfernandez and 3 guests