0

Firstly I am assuming DependencyProperty is what to use but I could be wrong - Maybe a INotifyPropertyChanged is more suitable?

I have a few UI controls that are all associated to audio playback. I would like to bind the Volume and Track Seek Sliders to a couple of doubles.

  • The volume slider will update the audio classes Volume variable when the Value is updated
  • The Track Seeking slider MaxValue will be set to the duration of the track in milliseconds and will update the seeking position variable of my audio playback class

New to Dependency properties and such so you help is much appreciated!

Dominic
  • 62,658
  • 20
  • 139
  • 163
  • If you want people to help out with your bindings you should first try and then post some code context if you failed (Including binding error messages from the Output window in VisualStudio). If you do not even have a clue how to start you should check out the [binding overview on MSDN](http://msdn.microsoft.com/en-us/library/ms752347.aspx). – H.B. Apr 30 '11 at 20:32

2 Answers2

2

You don't need dependency properties for that, simply implement INotifyPropertyChanged so the binding engine is aware of changes to your property.

H.B.
  • 166,899
  • 29
  • 327
  • 400
Femaref
  • 60,705
  • 7
  • 138
  • 176
1

DependencyProperties are for sparse data-structures like Controls which have a huge amount of properties of which only a few are set, this saves memory. If you bind to your own data DPs normally do not make that much sense because your properties will be set and you might want to access your data-object from different threads which is not easily possible with DependencyObjects.

Also see this question which compares the two in regards to using them in a ViewModel.

Community
  • 1
  • 1
H.B.
  • 166,899
  • 29
  • 327
  • 400