Node and link creation programatically on a button click

I want to create a node and connect it with a link to an existing port on a button click. I add the node and link in the model within a transaction. But the node and link don’t appear until I scroll the canvas, then on all links and nodes appear fine when I create them same way. I do a diagram.Panel.UpdateDiagramBounds(); after I add the node, link, still it takes a canvas scroll to show the created link and node. Or even the tab close and re-open brings them on the canvas. Some sort of refresh is missing. I tried calling a layout_completed but it did not help either. Does this behavior point to something very basic that am missing?

Yes, there must be something odd about your application, but it isn’t obvious to me what that might be.

Some of the samples demonstrate adding a Node and a Link to an existing Node, by changing the model within a transaction. For example look at the button click event handler in the State Chart sample. It might be doing more than you want to do, but I hope you can learn from it.

Thank you so much Walter, I added that piece of code where we call diagramPanel.MakeVisible and CenterPart particularly inside Model_Changed event and then it worked. Doing it inside Model_changed really did the trick.