Changing a Diagram Style property at run-time


This is GoXam Silverlight

Is changing the Style property of a Diagram, at run-time, supported?

When I try it I get inconsistent results.

Here is what a Diagram initially looks like with “Style A” set:

I then change the Style property of the Diagram to “Style B”:

I then change the Style property of the Diagram back to “Style A”. Sometimes this works and displays the same as in the first screenshot. However, sometimes artifacts of the previous Style remain:

Sometimes the Links don’t plot correctly:

Here’s the code we’re using to change the Style:


Diagram.Style = (Style)System.Windows.Application.Current.Resources[“MeasureDiagramStyle”];



I suspect that is because of the simple “virtualizing” that GoXam does in order to improve performance. You can disable that by adding this when you initialize the Diagram:

myDiagram.InitialLayoutCompleted += (s, e) => { myDiagram.Panel.Unsupported(23, false); };

By the way, you should not have to call RebuildLinkElements(). Perhaps you were just trying to figure out how to get around the problem.

Hi Walter

Thanks for the quick reply.

Using Diagram.Panel.Unsupported(23, false); solved the issue where parts of the previous Style were being displayed.

However, we’re still having issues with the Links not plotting correctly. We’ve tried the following:


But even after calling the above methods the links are still not plotted correctly. They are plotted against the ports (elements where PortId has been set) of the previous style.

The issue only occurs if the Node DataTemplates specify PortId values.
For eg:

<Rectangle Fill=“Transparent” Width=“6” Height=“6”
go:SpotPanel.Spot=“MiddleLeft” go:SpotPanel.Alignment=“MiddleLeft”
go:Node.PortId=“L” go:Node.LinkableFrom=“True” go:Node.LinkableTo=“True” Cursor=“Hand”
go:Node.FromSpot=“MiddleLeft” go:Node.ToSpot=“MiddleLeft” go:Node.LinkableDuplicates=“False” />

<Rectangle Fill=“Transparent” Width=“6” Height=“6”
go:SpotPanel.Spot=“MiddleTop” go:SpotPanel.Alignment=“MiddleTop”
go:Node.PortId=“T” go:Node.LinkableFrom=“True” go:Node.LinkableTo=“True” Cursor=“Hand”
go:Node.FromSpot=“MiddleTop” go:Node.ToSpot=“MiddleTop” go:Node.LinkableDuplicates=“False” />

<Rectangle Fill=“Transparent” Width=“6” Height=“6”
go:SpotPanel.Spot=“MiddleRight” go:SpotPanel.Alignment=“MiddleRight”
go:Node.PortId=“R” go:Node.LinkableFrom=“True” go:Node.LinkableTo=“True” Cursor=“Hand”
go:Node.FromSpot=“MiddleRight” go:Node.ToSpot=“MiddleRight” go:Node.LinkableDuplicates=“False” />

<Rectangle Fill=“Transparent” Width=“6” Height=“6”
go:SpotPanel.Spot=“MiddleBottom” go:SpotPanel.Alignment=“MiddleBottom”
go:Node.PortId=“B” go:Node.LinkableFrom=“True” go:Node.LinkableTo=“True” Cursor=“Hand”
go:Node.FromSpot=“MiddleBottom” go:Node.ToSpot=“MiddleBottom” go:Node.LinkableDuplicates=“False” />

The fours Rectangles above are four Link ports on the Node (Left, Top, Right, Bottom)

Any suggestions?


You really shouldn’t have to call Rebuild…, although it shouldn’t do any harm (besides waste time and space) if you do. It ought to be enough to call Link.Route.InvalidateRoute() on each Link.Route

I would have thought that calling LayoutDiagram would be sufficient too, but I think that depends on how the layouts are defined.

But if that doesn’t work, I’m not sure what’s going on in your app.

Thanks Walter, we’ll investigate things on our side and will let you know if find the problem/solution.