Set the default value of a dependency property
While creating a new control I wanted to set the value of a bool DependencyProperty to true.
I hoped to use [DefaultValue] on the property that invokes the DependencyProperty but this dit not work.
And it's not abnormal that this didn't work.
WPF does not go through the getters/setters, it talks to the DependencyProperty directly.
So after searching a little bit I found the following:
public static DependencyProperty IsFilteringCaseSensitiveProperty =
DependencyProperty.Register("IsFilteringCaseSensitive", typeof(bool), typeof(FilteringDataGrid), new PropertyMetadata(true));
You have to add the default value in the PropertyMetadata of your dependency property.