Page 1 of 1

C++ data binding with DependencyProperty or with use NsProp and (differences Question)

Posted: 07 Apr 2018, 16:54
by Wanderer
It looks like there are two ways for databinding (if I understand it right).
With NsProp() definition and use class INotifyPropertyChange or use DependencyProperty. When to use one and when to use another? The DependencyProperty way is most used on UserControl without INotifyPropertyChange from tutorials and some examples.

Re: C++ data binding with DependencyProperty or with use NsProp and (differences Question)

Posted: 09 Apr 2018, 09:52
by realesmedia
It looks like there are two ways for databinding (if I understand it right).
With NsProp() definition and use class INotifyPropertyChange or use DependencyProperty. When to use one and when to use another? The DependencyProperty way is most used on UserControl without INotifyPropertyChange from tutorials and some examples.
Use NsProp when you need your own getter or setter and use dependency when you need just a mirror of value.

Re: C++ data binding with DependencyProperty or with use NsProp and (differences Question)

Posted: 09 Apr 2018, 11:55
by Wanderer
What you mean "mirror of value"?

Re: C++ data binding with DependencyProperty or with use NsProp and (differences Question)

Posted: 09 Apr 2018, 17:39
by sfernandez
DependencyProperties are used (usually on controls) when your property requires advanced features like DynamicResources, Styling, Bindings, Animation...
A dependency property automatically provides an internal mechanism for property change notification, so they don't need the INotifyPropertyChanged interface.

If you just need a property to expose some data, you can use a simple reflected property (NsProp), and implement INotifyPropertyChanged interface only if you want to notify when that property changes its value to update the UI.

Re: C++ data binding with DependencyProperty or with use NsProp and (differences Question)

Posted: 09 Apr 2018, 18:48
by jsantos
Just to make this clear:

1. If you are implementing a UserControl -> DependencyProperty
2. If your are exposing a property in your DataContext for DataBinding -> Reflection property (NsProp)

Re: C++ data binding with DependencyProperty or with use NsProp and (differences Question)

Posted: 09 Apr 2018, 19:58
by Wanderer
Thanks all.

Re: C++ data binding with DependencyProperty or with use NsProp and (differences Question)

Posted: 13 Apr 2018, 13:08
by jsantos
You welcome, I am marking this as solved.