Databinding in WPF is very flexible and can therefore be less obvious at times.
* You can use the "/" to specify the current item in a collection.
I'm not going into any details, you should definitely read Ian Griffiths' article on this!
* I'm using the following xaml to fill the dataContext in my controlTemplate:
DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}"
The application works fine, but Cider (Visual Studio Designer) complains that I must set the Path property.
I'm interested in the entire object, and not a specific property though.
You can fix this by using the Path=. notation, which resolves to the same object.
Did you know readme files can contain useful information? :p [check out section 2.3.8.7]
* Binding path "TextBox.Text" vs "Text"?
If you bind to a path called Text, WPF uses reflection to resolve the name. If you use the class-qualified name, binding avoids the reflection performance hit. Class-qualified names also allows binding to attached properties!
* Not all DP's have the same default binding mode
You'll get in trouble if the binding mode is two-way, but the CLR property that it is bound to is read-only... You can't assume what the binding mode is!
It is always a good idea to explicitly specify your binding mode. Also remember that OneWay is slightly lighter than TwoWay!
* RelativeSourceMode.PreviousData
If you bind to a collection of objects and need to show the change from the previous item the current item then this little trick can be very useful...
Pass the current item and the following binding into a IMultiValueConverter
{Binding RelativeSource={RelativeSource PreviousData}}
The multi value converter now just need to work out what the difference is!