Wanderer
Topic Author
Posts: 168
Joined: 08 May 2017, 18:36

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

07 Apr 2018, 16:54

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.
 
realesmedia
Posts: 85
Joined: 18 May 2016, 10:26

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

09 Apr 2018, 09:52

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.
 
Wanderer
Topic Author
Posts: 168
Joined: 08 May 2017, 18:36

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

09 Apr 2018, 11:55

What you mean "mirror of value"?
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

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

09 Apr 2018, 17:39

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.
 
User avatar
jsantos
Site Admin
Posts: 3906
Joined: 20 Jan 2012, 17:18
Contact:

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

09 Apr 2018, 18:48

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)
 
Wanderer
Topic Author
Posts: 168
Joined: 08 May 2017, 18:36

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

09 Apr 2018, 19:58

Thanks all.
 
User avatar
jsantos
Site Admin
Posts: 3906
Joined: 20 Jan 2012, 17:18
Contact:

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

13 Apr 2018, 13:08

You welcome, I am marking this as solved.

Who is online

Users browsing this forum: No registered users and 89 guests