Contextual Graph Layout ignoring Layout Algorithm

Jul 3, 2009 at 9:03 AM
Edited Jul 3, 2009 at 9:06 AM


I've been playing around with the graph sharp library, and trying to get the ContextualGraphLayout to work.

I have the following class:

public class MyGraphLayout : ContextualGraphLayout<MyNode,MyEdge,MyGraph> {}

And the following model object:

public class GraphModel : INotifyPropertyChanged
public MyGraph Graph {get;set;}
public MyNode SelectedVertex {get;set {...};}
public PropertyChangedEventHandler PropertyChanged;

In my window, I have the following:

<local:MyGraphLayout x:Name="myLayout" Graph{Binding Graph}
SelectedVertex={Binding SelectedVertex} 

In the Window Load function I have some code which adds a few vertices and edges to an instance of the GraphModel, and sets that as the datacontext on the myLayout control.

I have no problem with accessing the contextual layout selected vertex change events, but the graph does not seem to be laying out (all nodes appear overlapping, I have to drag them apart).

If I change the MyGraphLayout definition to GraphControl instead of ContextualGraphControl (and remove the SelectedVertex binding) the graph is layed out fine in a nice animated fashion (as expected).

Changing the LayoutAlgorithmType and OverlapRemovalAlgorithmType doesn seem to make any difference.

I've based my quick test on the ContextualLayout example provided in the sample project.

Does anyone have any ideas?