Binding a total object

Hi,

Is it possible to bind a total object, e.g. a Shape or Figure or do I always have to bind on properties of the objects?

So for example for this Shape:

$(go.Shape, {
    figure: "Circle",
    width: 10,
    height: 10,
    fill: "blue",
})

Can I make a binding that returns the shape instead of binding to all properties of this shape?

No, binding only sets properties. It cannot change the structure (the visual tree) of a Part, other than when setting Panel.itemArray.

But you could bind GraphObject.visible or opacity.

Thanks, I could use the visible property to hide specific elements. Would there be a performance gain if I would introduce multiple templates with and without specific objects; or would this be the same as setting the object visible property to false?

That’s hard to say. If there are enough structural differences, it might make sense to use a different template. But discarding a Part’s visual tree and copying the new template’s visual tree and re-evaluating bindings, followed by re-measuring and re-arranging the Part and maybe re-layout of the diagram, can be very expensive.

Changing opacity is faster than changing visibility, because the former just requires a re-draw, whereas the latter requires re-measuring and re-arranging the Part, and that might cause a re-layout of the diagram.

Thanks; I will test the different set-ups then :)