I’m new to GoXam so this may be something simple but I’ve been racking my brain since yesterday…
My problem is that when I try linking two objects together in my Diagram, it throws this exception:
{System.InvalidOperationException: Override InsertLink(NodeType, PortKey, NodeType, PortKey) to support creating a new link
at #w.#P.#tc(IDiagramModel model, String msg)
at Northwoods.GoXam.Model.GraphLinksModel`4.InsertLink(NodeType fromdata, PortKey fromparam, NodeType todata, PortKey toparam)
at Northwoods.GoXam.Model.GraphLinksModel`4.AddLink(NodeType fromdata, PortKey fromparam, NodeType todata, PortKey toparam)
at Northwoods.GoXam.Model.GraphLinksModel`4.#rn(Object fromdata, Object fromparam, Object todata, Object toparam)
at Northwoods.GoXam.Tool.LinkingTool.DoMouseUp()
at Northwoods.GoXam.DiagramPanel.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at Northwoods.GoXam.DiagramPanel.#Iz(Object s, MouseButtonEventArgs e)
at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)}
I have a toolkit:Accordion object with a go:Palette inside of a few AccordionItem objects - so I have multiple go:Palette objects on my page that hold different categories of parts. I can drag items onto the Diagram just fine. Here’s how my palette area is set up:
<toolkit:Accordion Margin="2" BorderBrush="Black" Padding="5" SelectionMode="OneOrMore">
<toolkit:AccordionItem Header="Junction">
<ContentControl>
<StackPanel Orientation="Vertical">
<go:Palette Grid.Row="0"
x:Name="pJunction"
BorderBrush="Transparent"
BorderThickness="0" Padding="5"
HorizontalContentAlignment="Left" VerticalContentAlignment="Top"
NodeTemplate="{StaticResource PaletteNodeTemplate}">
<go:Diagram.Layout>
<golayout:GridLayout CellSize="10 10" />
</go:Diagram.Layout>
</go:Palette>
</StackPanel>
</ContentControl>
</toolkit:AccordionItem>
<toolkit:AccordionItem Header="ROV">
<ContentControl>
<StackPanel Orientation="Vertical">
<go:Palette Grid.Row="0"
x:Name="pROV"
BorderBrush="Transparent"
BorderThickness="0" Padding="5"
HorizontalContentAlignment="Left" VerticalContentAlignment="Top"
NodeTemplate="{StaticResource PaletteNodeTemplate}">
<go:Diagram.Layout>
<golayout:GridLayout CellSize="10 10" />
</go:Diagram.Layout>
</go:Palette>
</StackPanel>
</ContentControl>
</toolkit:AccordionItem>
</toolkit:Accordion>
My DataTemplates are set up like this:
<DataTemplate x:Key="PaletteNodeTemplate">
<StackPanel go:Part.SelectionElementName="Icon">
<TextBlock Text="{Binding Path=Data.OBJECT_TITLE}" HorizontalAlignment="Center" />
<Image x:Name="Icon"
Source="{Binding Path=Data.OBJECT_IMAGE}"
Width="{Binding Path=Data.PALETTE_WIDTH}" HorizontalAlignment="Center" />
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="DiagramNodeTemplate">
<go:NodePanel>
<StackPanel go:Part.SelectionElementName="Icon" Cursor="Hand">
<Image x:Name="Icon"
Source="{Binding Path=Data.OBJECT_IMAGE}"
Width="{Binding Path=Data.DIAGRAM_WIDTH}" HorizontalAlignment="Center"
go:Node.PortId=""
go:Node.LinkableFrom="True" go:Node.LinkableTo="True"/>
<TextBlock Text="{Binding Path=Data.OBJECT_ID}" />
</StackPanel>
</go:NodePanel>
</DataTemplate>
<DataTemplate x:Key="LinkTemplate">
<Path go:LinkPanel.IsLinkShape="True" Stroke="Orange" StrokeThickness="11"
go:Part.SelectionAdorned="True" go:Part.Reshapable="True">
<go:Link.Route>
<go:Route Routing="Orthogonal" Corner="4"
RelinkableFrom="True" RelinkableTo="True" />
</go:Link.Route>
</Path>
</DataTemplate>
And my diagram:
<go:Diagram x:Name="myDiagram" Grid.Column="1" Padding="10"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
GridSnapEnabled="True"
ContextMenuEnabled="True"
NodeTemplate="{StaticResource DiagramNodeTemplate}"
AllowDrop="True"
LinkTemplate="{StaticResource LinkTemplate}">
</go:Diagram>
And here’s my code-behind:
//Junction
var pmodel = new GraphLinksModel<Component, String, String, MyModel>();
pmodel.NodeKeyPath = "OBJECT_ID";
pmodel.NodesSource = new ObservableCollection<Component>() {
new Component() { OBJECT_ID="JUNCTION1", OBJECT_GROUP="JUNCTION", PALETTE_WIDTH="60", DIAGRAM_WIDTH="60", OBJECT_TITLE="JUNCTION 1", OBJECT_IMAGE="http://localhost/Images/Junction/J_Box.png" }
};
pmodel.Modifiable = true;
pJunction.Model = pmodel;
//ROV
pmodel = new GraphLinksModel<Component, String, String, MyModel>();
pmodel.NodeKeyPath = "OBJECT_ID";
pmodel.NodesSource = new ObservableCollection<Component>() {
new Component() { OBJECT_ID="ROV1", OBJECT_GROUP="ROV", PALETTE_WIDTH="60", DIAGRAM_WIDTH="120", OBJECT_TITLE="ROV 1", OBJECT_IMAGE="http://localhost/Images/ROV/ROV_Straight_L.png" },
new Component() { OBJECT_ID="ROV2", OBJECT_GROUP="ROV", PALETTE_WIDTH="60", DIAGRAM_WIDTH="120", OBJECT_TITLE="ROV 2", OBJECT_IMAGE="http://localhost/Images/ROV/ROV-061-01-4-4_L.png" },
new Component() { OBJECT_ID="ROV3", OBJECT_GROUP="ROV", PALETTE_WIDTH="60", DIAGRAM_WIDTH="120", OBJECT_TITLE="ROV 3", OBJECT_IMAGE="http://localhost/Images/ROV/ROV-361-01-4-2_L.png" }
};
pmodel.Modifiable = true;
pROV.Model = pmodel;
pmodel.HasUndoManager = true;
myDiagram.AllowDrop = true;
-------------------------------
public class Component : GraphLinksModelNodeData<String>
{
public String OBJECT_ID { get; set; }
public String OBJECT_GROUP { get; set; }
public String OBJECT_TITLE { get; set; }
public String PALETTE_WIDTH { get; set; }
public String DIAGRAM_WIDTH { get; set; }
public String OBJECT_IMAGE { get; set; }
}
public class MyModel : GraphLinksModel<Component, String, String, MyLinkData>
{
// nothing to add or override, for now
}
public class MyLinkData : GraphLinksModelLinkData<String, String>
{
// nothing to add or override, for now
}
Any help would be greatly appreciated!!