Diagram background

In my application I let the user choose diagram background color, but sometimes when changing color only the diagram border changes color. I have found out that in such cases the background changes when for example the form is resized or if I programatically turn on and off the grid. How can I force the background allways to change?

This is my code to change background:
myDiagram.Background = Brushes.White
I'm using wpf edition.

Control.Background isn’t our property of course, so we don’t have control over how it is implemented. But…

If you look at the ControlTemplate for Diagram (in docs/GenericWPF.xaml) you’ll see the binding of Border.Background="{TemplateBinding Background}".

You can replace this binding with your own more-dynamic binding.

Or you can set it directly in code.