I’m trying to declare my model using interfaces instead of concrete types, like so:
public class MyModel : GraphLinksModel<INode, INodeKey, string, ILink>
{
public MyModel
{
Modifiable = true;
}
}
I then create a new instance of the Node class, explicitly assign its Key property, and call MyModel.AddNode(). I always get back an InvalidOperationException with the text:
“Found duplicate key ‘null’ for node; override MakeNodeKeyUnique to modify data”
I overrode MakeNodeKeyUnique just so I could have a breakpoint. I verified that the nodedata that gets passed in actually has a key value (and since it’s the first node in the diagram it’s unique). But it looks like GoXam is thinking the key is null. (My implementation of INodeKey is a class that overrides the virtual bool Object.Equals(object) method. It does not implement INotifyPropertyChanged, IChangeDataValue, or ICloneable.)
When I switch my model definition to use concrete types for the node and link types, everything just works:
public class MyModel : GraphLinksModel<<font ="apple-style-span"="" color="#ff0000">Node</font>, INodeKey, string, <font ="apple-style-span"="" color="#ff0000">Link</font>>
{
public MyModel
{
Modifiable = true;
}
}
What the heck is going on?
edit: I’m running in Silverlight 4, if it matters.