One is from a class testresize.model.ts, this class inherit from go.Node, and implement the template
One is a function in testresize.model.ts, this function do the exact same thing, except that the go.node is instanciated. (I don’t want to keep this function, this is just to show you the problem)
I don’t understand why the solution 1 isn’t working.
For unknown reasons your code doesn’t run at all. But at least I can see your code.
The problem with your TestResize class is that the constructor is allocating and adding some elements – a Panel and a Shape and a TextBlock. But that will cause a problem as soon as a TestResize is copied – the TestResize constructor is called and then it walks the visual tree, copying each of the elements, resulting in duplicate elements. There might be other problems too. So don’t do that.
I’m wondering why you wanted to subclass Node. The only good reason that I know of is to override one or two methods for which there is no alternative. And maybe we ought to extend the API so even those reasons are no longer necessary.