Missing node?

I finnaly have an other issue…
As you can see in this picture, this is my Diagram. Alpha and Teta were created at the beginning and I try to drag Triangle on my diagram.

Alpha and Teta that you can see on the topleft are nodes I find in loop :
foreach (Node node in myDiagram.Nodes)

As you can see, Triangle doesn’t seem to be part of my diagram… Have you an idea why I can’t find it in my loop? What could I forgot? :$

After droping a node on my diagram, I must be able to find it in my diagram nodes, no?

I assure you that all Nodes will be in the myDiagram.Nodes collection. Why don’t Epsilon and Gamma and Delta and Beta show up in your computed list?

I don’t know… I tried to show a messagebox at each turn of my loop, after seeing the second node nothing works…

I tried with only one node in my diagram, it works fine but if I create 2 nodes, my diagram freeze…

I create these 2 nodes :

new MyData() { Key=“Alpha”, Title=“Alpha”, Color=“LightBlue”, Text=“Premiere lettre greque”, Figure=NodeFigure.Triangle, Category=“NodeTemplate”},
new MyData() { Key=“Teta”, Title=“Teta”, Color=“Yellow”, Text=“Inconnu”, Figure=NodeFigure.Circle, Category=“NodeTemplate”}

If I create one of them it works, but If I create both of them it doesn’t…

myDiagram.Nodes contains all my diagrams node, no?

Sorry, It works, I am juste a stupid guy, It was my messageBox I think…

Thx again, I hope it is going to work :)

I finally succeded, I had an issue with group but I found a solution :)

However, I still have 2 questions, at first, what should I do to actualize my node template? Because it actually actualize only after clicking on it…

The second one is that if I called my function AddSpotToNodes(); in public MainPage(), my spots are not modified but If I call it after clicking on a button, it works… I don’t understand the difference… MyDiagram already exist at the end of MainPage(), no? :O

The Diagram might exist at the end of the page constructor, but that doesn’t mean all of the Parts do. You might want to do initialization based on geometry and panel layouts in a Diagram.InitialLayoutCompleted event handler.

Thx but I don’t understant how I can use that :$

Is there an exemple in your samples to see how I could use it?

You could try searching the samples or reading the documentation.

Thx, I found it :)

I tried to use myDiagram.ExternalObjectsDropped to create my spots when I drop a new node on my diagram.

In this case, does “sender” contain the node I droped on the diagram?

Use Diagram.SelectedParts.

If I used Diagram.SelectedParts, my function will not be called only on droping new node in my diagram…

There is no better function?

I found Diagram.NodeCreated but it doesn’t work too…

Moreover, I am talking about droping a new node on my diagram (node is taken from my Palette)

If I call my function on Diagram.SelectedParts it doesn’t work… I think it’s because my nex node location isn’t already set, am I wrong? :$

For several of the Diagram events the implicit subject is the collection of selected Parts.

Diagram.NodeCreated is raised by the ClickCreatingTool, as you can see in the documentation for the event.

I saw it was raised by ClickCreatingTool…

Thx for your help

I still have my issu, I try to find my new spot when the user is dragging the new node on my diagram.

For that I use SelectedPartsChanged but the value of node.ActualHeight is 0…
I don’t understand why? Is it set after the node being drop? If yes, is it a way to force its calculation? :$

If you want to look at the Parts that were dropped, i.e. after the drop, you should use the ExternalObjectsDropped event handler and look at the SelectedParts. At that time the ActualHeight ought not to be zero any more.

Remember that WPF and Silverlight set the ActualHeight after the element has been arranged. That happens “asynchronously”.

I suppose you could override methods of DraggingTool, but you haven’t detailed exactly what you really want to do.