Registering port changes with undo manager

My nodes have an ItemsControl for the ports. The ItemsSource for the ItemsControl is a CollectionViewSource whose Source is bound to an ObservableCollection. I want to have changes to that ObservableCollection (adding and removing ports) register as a transaction with the UndoManager. Is there any way to do this?

Yes. In fact, the Dynamic Ports sample demonstrates exactly that.
Although it might be more complicated than you need, because it manages four separate lists, not just one, per node.

In that sample, the nodes correspond to node data of type Unit. The ports correspond to the node sub-data of type Socket.