How to hide nodes and update layout?

I have a toggle button that, based on its value, it hides/shows some nodes in a diagram. The problem is, say I have 15 nodes that are horizontally laid out. This will cause the horizontal scroll bar to show up. But when I toggle the button that causes 10 of those nodes to be hidden, the scroll bar still doesn’t refresh (in this case disappear because it no longer is needed) its visibility. Is there a way to accomplish this behavior?

Changing Part.Visible automatically causes the DiagramBounds to be updated. Then when the DiagramBounds is smaller than the ViewportBounds, no scrollbar is needed to be shown.

So how are you hiding your nodes? Are you setting or binding Part.Visible? If you just change the Node.Visibility, the node is still taking up space.

I was using Node.Visibility so I changed it to Node.Visible and it’s still showing the same behavior.

I just tried this, and it worked as I think you (and I) were expecting:

private void Button_Click(object sender, RoutedEventArgs e) { myDiagram.StartTransaction("Hide"); foreach (Node n in myDiagram.Nodes) { if (n.Bounds.X > 500) n.Visible = false; } myDiagram.CommitTransaction("Hide"); }

Great. Putting it in a transaction did the trick. Thx