internal static bool CopyDependencyPropertyValue(DependencyProperty dependencyProperty, DependencyObject source, DependencyObject target) { var valueSource = GetValueSource(source, dependencyProperty); switch (valueSource) { case PropertyValueSource.Default: target.ClearValue(dependencyProperty); return(true); case PropertyValueSource.Local: target.SetValue(dependencyProperty, source.GetValue(dependencyProperty)); return(true); case PropertyValueSource.LocalBinding: target.CopyBinding(source, dependencyProperty); return(true); case PropertyValueSource.Inherited: return(false); default: throw new ArgumentOutOfRangeException(); } }