I am using the Entity relationship example as a base. The database I am testing with is the microsoft adventureworks database which has 71 nodes and 92 links. Each node contains a Microsoft datagrid.

When loading a diagram model programmatically I get the following times:
At event ModelReplaced 14 sec.
At event LayoutLoaded 22 sec.
Total 36 sec.
Note - The LayoutLoaded event is not available in xaml.

Execute Method Diagram.LayoutDiagram 27 sec.

Does this performance seem reasonable???

I am setting the following programmatically:

LayeredDigraphLayout ldl = new LayeredDigraphLayout();
ldl.InitializeOption = LayeredDigraphInitIndices.DepthFirstIn;
ldl.LayerSpacing = 75.0;
ldl.SetsPortSpots = false;
myDiagram.Model.Modifiable = true;
myDiagram.Layout = ldl;

Grid.Row=“1” x:Name=“myDiagram”
NodeTemplate="{StaticResource NodeTemplate}"
LinkTemplate="{StaticResource LinkTemplate}">

            <go:LayoutManager Animated="True" DefaultLocation="0 0"   />

        <!-- this node implements a mode-less form that can be dragged around
        and scrolls around to stay near the node it is detailing -->
        <go:Node Id="myDetails">
            <local:EntityForm go:Part.LayerName="Foreground" go:Part.Visible="False"
                      go:Part.Deletable="False" go:Part.Copyable="False" />
            <LinearGradientBrush StartPoint="0.0 0.0" EndPoint="1.0 0.0">
                    <GradientStop Color="White" Offset="0.0" />
                    <GradientStop Color="White" Offset="0.4" />
                    <GradientStop Color="White" Offset="1.0" />

The time to create all of the nodes might be reasonable, since most of that time is going into realizing all of those DataGrids.

I would use ForceDirectedLayout for such a diagram, not LayeredDigraphLayout. I don’t think it’s inherently layered, so a different layout would make more sense.


I changed to force directed but that did not help much. Can you recommend a lightweight replacement for the datagrid. All I need is a check box and the field name for each column.


I modified the EntityRelationship sample to create 80 nodes.

The creation of the model only takes a fraction of a second.

Performing the layout takes either less than a second (ForceDirected) or a couple of seconds (LayeredDigraph).

[An aside: the Silverlight run-time is significantly slower than the regular .NET CLR. Still, I think it doesn’t matter here. Also, all times I report here are wall-clock times, not CPU usage times.]

The majority of the time goes to creating the Nodes and Links. There was some variation in times – once less than 10 seconds, but usually 14-17 seconds.

There was also significant time going into rendering, which is harder to measure since it’s asynchronous to our code. The total rendering-only time might have been around 10 seconds.

For comparison, running the Class Hierarchy sample in my test took about 1.5 seconds for 135 nodes, total. Of course the big difference there is that the NodeTemplate is pretty simple: just a TextBlock and a ToolTip.

I suppose you could try replacing the DataGrid in your NodeTemplate, but I think you won’t be able to save much time.

Perhaps you could use a simple template and then asynchronously elaborate nodes with the desired DataGrid. I’d have to think about the best way for you to do that.

Hmmm. Out of curiousity, I compiled the demo normally and ran the ER sample without VS2008 and debugging, just as a XAP in an HTML page.

It was consistently twice as fast: usually 12-13 seconds elapsed, total.