Diagram Background Image

I am setting a watermark using the Diagram Background property. This property is an brush so I’ve added an imagebrush that uses a watermark to the image that has an opacity value.

I have noticed some odd behaviour, first when scrolling the diagram for the first time the image appears darker at first. Also when scrolling a trailing duplicate of the image appears slightly behind it. When the background brush is set to null during runtime to hide the background the image goes lighter but does not disappear completely until the diagram is scrolled. Finally when changing the scale on the diagram 2 versions of the image appear, one that scales correctly and one fixed at the original size.

This all leads me to believe that for some reason a duplicate of the background brush is created for some reason and updated when the viewport is changed. Removing the opacity can resolve some of the issues but my biggest remaining problem is that the image will not clear when the background brush is set to null. Is there any way this duplicate background can be removed?

I just tried adding an ImageBrush as a resource:

and then set the Diagram.Background:
<go:Diagram …
Background="{StaticResource Star}"
. . .

Everything worked fine. The background image was stable, resized appropriately when I resized the window containing the Diagram, and did not move when I zoomed in or scrolled.

So I would check your Diagram.Template, if you have replaced the standard ControlTemplate.
Also you might want to see if there are any other uses of the image or brush anywhere in your app. Maybe you have created an unbound Node using the image, to act as a scrollable/zoomable background? (Hmm, that would not entirely explain the behavior that you see.)

Remember that you must not use the DiagramPanel.Background, because that is reserved for GoXam’s use.

There are no duplicates of the image being generated by me and this issue can be seen either by defining the brush in xaml or assigning to the Diagram.Background brush value in code if opacity is applied to the image.

Mine works fine when no opacity is in the image except when try to remove the brush at runtime. It will work for me if I can use an image with no opacity and it can be disabled or cleared at runtime but I believe the cause of the issue is due to an extra image that is generated for some reason and is visible by setting the opacity on the image.

I was using an image with a transparent background, but I’ll try again with partial opacity.

Try replacing the Diagram.Template with a ControlTemplate that does not have a Border surrounding everything.

I am puzzled about what’s going on. Perhaps the window system is caching the background for performance reasons.

I have tried removing the border but I have the same problem. Also I had the same problems with an image that has an opaque background rather then an image brush opacity setting. This may be a problem specific to our application.