Diagram Background Not Loading

I am using a node to draw a background grid for our diagram. There is also a system that saves the page layout and diagram bounds and viewport position to a file. The diagram has bounds created based on the selected paper size. If the viewport is saved in a position to far from the top left of the diagram grid when the diagram is reloaded the grid will not show up until the viewport is scrolled near the top left of the diagram. The workaround I have found is to force the file to open at the top left of the diagram. Is there anyway this can be resolved without having to open the diagram at the top left?

What Diagram.Initial… properties have you set?

InitialPosition and InitialScale

I’m not sure what the problem might be. I’m wondering if there’s a problem with asynchrony.

Have you tried setting the Diagram.Panel.Position in either a Diagram.InitialLayoutCompleted event handler, or even after that?

I tried setting the position in the InitialLayoutCompleted event but I’m still having the same problem. Anything else I can try?

Not that I can think of – I can try to reproduce the problem.

Another possibility: are you sure you want to use a GridPattern in a Node? If you don’t mind using an infinite background grid, you can set the Diagram.GridPattern and related properties.

I just tried to recreate the situation you described. I probably am not doing the same thing as you, but I was unable to detect any problem.

Here’s my Diagram:

<go:Diagram Grid.Row="1" x:Name="myDiagram" Padding="10" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" . . .> <go:Node> <go:GridPattern Width="400" Height="400" Background="BlanchedAlmond" go:Node.Location="0 0" go:Part.LayoutId="None" go:Part.Selectable="False"> <Path Stroke="Blue" StrokeThickness="1" go:GridPattern.Figure="VerticalLine" /> <Path Stroke="Red" StrokeThickness="1" go:GridPattern.Figure="HorizontalLine" /> </go:GridPattern> </go:Node> </go:Diagram>
And here’s my initialization code, beyond the standard model initialization:

myDiagram.TemplateApplied += (s, e) => { myDiagram.Panel.FixedBounds = new Rect(-1000, -1000, 3000, 3000); myDiagram.InitialScale = 2; myDiagram.InitialPosition = new Point(-800, 0); };

I have worked around this by loading the diagram at the top left of the bounds. I’ve seen this issue at other times at well and the solution was to call Diagram.LayoutDiagram(). This still doesn’t seem to resolve the issue on the initial load if the diagram isn’t loaded at the top left.

We can’t get the problem to occur here. Could you try to reproduce the problem in a small sample application?