I’ve often had a need to check whether DependencyProperty holds its default value and surprisingly it is not as easy to find how to do that. So I present IsDefaultValue method:

public bool IsDefaultValue(DependencyObject targetObject, DependencyProperty dp)
{
    return System.Windows.DependencyPropertyHelper.GetValueSource(targetObject, _
       dp).BaseValueSource == BaseValueSource.Default;
}

And that’s it!

As bonus, if you look into the BaseValueSource enum you might find other interesting things 😉

Professional looking applications made easy with DotNetBar for WinForms, Silverlight and WPF User Interface components. Click here to find out more.