Multiselection : at least one node is selected?


I have a button which should be enable only if at least a node is selected.

I’ve binding button’s IsEnabled property on SelectedNode (via converter).

All is ok, even in multiselection if no link are selected.

Some trouble appears when I also select link (for example by drag/drop selection) SelectNode is null.

Binding on SelectedPArts is not possible because it is a collection.

Is there exist a more direct way, than suscribing to SelectedPArts.Collectionchange for maintain a boolean bOneNodeIsSelected. ?


Why not define a converter that looks at Diagram.SelectedParts that returns true if there’s at least one Node in that collection?

It was what I’ve tried, but binding fire only one time, because SelectedParts is set one time after it’s only add or remove.


Ah, that’s right: because the data-binding doesn’t recognize changes to the contents of the collection.

OK, what you suggested sounds good: define a Diagram.SelectionChanged event handler that does what you want. That’s basically the same as defining a CollectionChanged event handler on the collection.

ok, I will do.