This question is a little connected with the previous one here
Generally I write an application which allows user to create his own graph and then get the shortest path. I got stucked with graphical representation.
I've rarely used XAML and have no idea how to connect methods in code-behind with XAML code.
I get the coordinates of mouse click in Canvas and it works great
private void mouseDoubleClick(object sender, MouseButtonEventArgs e)
{
int x = (int)e.GetPosition(dataCanvas).X;
int y = (int)e.GetPosition(dataCanvas).Y;
currentMap.CreateNodes(x, y, "ExampleNode");
targetText.Text = x.ToString() + "X " + y.ToString() + "Y "; // Just for debugging
}
Here is the CreateNode definition:
public void CreateNodes(int x, int y, string name)
{
Node node = new Node(name);
this.places.Add(node);
node.X = x;
node.Y = y;
GUI.CreateNode(node);
}
But problem is still here
//GUI class
public static void CreateNode(Node n)
{
Point point = new Point(n.X, n.Y);
}
This method should draw the image in the specific (x, y) place. I have the coordinates and have to somehow create an image there. As I said I'm not fluence with using XAML and don't know how to connect this code with adjusting canvas in XAML to create and manipulate an image.
I was given a link here
but I'm not sure how to use it in my project. Am I supposed to create an ObservableCollection and then use the code from the link...?
Any help would be appreciated.
Here you have the interface: here