private static void _OnChromeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
// The different design tools handle drawing outside their custom window objects differently.
// Rather than try to support this concept in the design surface let the designer draw its own
// chrome anyways.
// There's certainly room for improvement here.
if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(d))
{
return;
}
var window = (Window)d;
var newChrome = (WindowChrome)e.NewValue;
Assert.IsNotNull(window);
// Update the ChromeWorker with this new object.
// If there isn't currently a worker associated with the Window then assign a new one.
// There can be a many:1 relationship of to Window to WindowChrome objects, but a 1:1 for a Window and a WindowChromeWorker.
WindowChromeWorker chromeWorker = WindowChromeWorker.GetWindowChromeWorker(window);
if (chromeWorker == null)
{
chromeWorker = new WindowChromeWorker();
WindowChromeWorker.SetWindowChromeWorker(window, chromeWorker);
}
chromeWorker.SetWindowChrome(newChrome);
}