Getting a Reference to the View

I need to get a reference to the View from a Node.

Do I have to add the Node to a Layer to accomplish this. Is there no other way to get a reference to the View this Node is in?

Which GoView? There might be several showing a node, or there might be none.

What do you really want to do?

The GoView that the Node is currently on. I want to call a method on the View from a node on it.

The documentation shows a View property on the Node but says it's null unless the node is in a layer.

A GoDocument can be displayed by any number of views... so the nodes don't know what view(s) they are in. What you are talking about is "view specific" GoObjects like selection handles (see the section on Ownership in the User Guide).

Typically, EventHandlers will be called with view context if you might need that. What’s your situation?

I have nodes that are related via a common key property. I want to make a call from one node to the view to find the coresponding node.

It’s easier to add state to the GoDocument rather than to the GoView, for various reasons. GoObject.Document will be non-null for those objects you have added to the GoView.Document in order to display them in the view.

GoObject.View will be non-null only for those special objects that are explicitly added to the view’s layers. Jake mentioned selection handles, but there is also the view’s grid and (optional) sheet of paper.