private static void OnHeaderBrushColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
// determine the contrast and set black or white
if (e.OldValue != e.NewValue)
{
SolidColorBrush newBrush = e.NewValue as SolidColorBrush;
if (newBrush != null)
{
var yiq = ((newBrush.Color.R*299) + (newBrush.Color.G*587) + (newBrush.Color.B*114)) / 1000;
Debug.WriteLine(yiq >= 128 ? "black" : "white");
}
}
}