Binding error in xaml: Object reference not set to an instance of an object.

Jan 22, 2016 at 7:59 PM
Edited Jan 26, 2016 at 1:59 PM
I follow the example, but visual studio shows an error in xmal file "Object reference not set to an instance of an object." on Graph="{Binding Graph}"
public Graph<Person> Graph
            get { return _graph; }
                SetProperty(ref _graph, value);
                Graph="{Binding Graph}"
Jan 26, 2016 at 12:16 AM
Edited Jan 26, 2016 at 12:17 AM
Hi hypertrix,

why do you use dependency property on your ViewModel? You can simply use regular auto-property like in the example:
public Graph<Person> Graph { get; private set; }
Then you also need to set it up with some data. In the example, this is done in the constructor
            var graph = new Graph<Person>();
            var a = new Person(graph) { Name = "Jonh", Avatar = "./Avatars/avatar1.jpg" };
            // ... etc
            this.Graph = graph;
Jan 26, 2016 at 4:09 PM
Edited Jan 26, 2016 at 4:16 PM
I want to refresh the graph when new data comes in: 1) clear the graph, 2) add vertex and edges based on new data. I didn't find an easy way to clear the graph, so every time I create a new graph and assigned it to Graph.

If I use Graph.RevmoeVertexWithEdges(v), an exception was thrown during layouting.Exception message: An item with the same key has already been added.. Could you shed some light on it? Thanks!
Nov 27, 2016 at 11:58 AM
I'm interested in this last topic as well: How to reload a completely different graph.

Best regards,
Michael Herman (Toronto)