Stretch node across whole diagram

Hello,

I’m supposed to draw lines in the background and I want them to stretch over the whole diagram, so they increase their size whenever the diagram’s size changes. Imagine an ever repeating background image in css. The line’s are drawn dynamically so I can’t actually use a background image. Is it possible to bind a node’s width to the diagram’s width?

I don’t know about such a Binding, but I suppose that should be possible.

An alternative would be to draw the background image dynamically, whenever needed, and tiling the background with it.

What should happen when the user zooms in or out?

Well, there is no actual image. The diagram’s width is defined by its content as this is the default behavior if I’m correct. The content is dynamic, though, and thus the width is also dynamic.

Upon zoom, the node should behave just like any node, and zoom accordingly

Well, I had been suggesting that you could implement your own tiled background image for the Diagram, as the Diagram.Background. But if you want the image to scroll and zoom just like the rest of the diagram’s contents, then this wouldn’t work.

But you could still do something similar. Add a single unbound Node to the Diagram (see the section about “Decorative Elements and Unbound Nodes” in the GoXamIntro.pdf document). Have the Node contain a Rectangle whose Rectangle.Fill you set to a VisualBrush that draws all of the lines and whatever that you want to tile as the background (set Viewport and TileMode).

Then implement a DiagramPanel.DiagramBoundsChanged event handler that sets that unbound Node’s Node.Position to be the DiagramPanel.DiagramBounds.Position and that node’s Rectangle’s Width and Height to be the DiagramPanel.DiagramBounds.Size.