This isn't how you are supposed to get the selected items.
The recommended approach is to create a command for your feature, which will then get called with the selection of items -- either from the tree, the list, the item editing screen, or some other context.
The idea is that your command should work regardless of the UI controls that might use it. It should be decoupled from the inner workings of those controls.
So, for instance, if you add an option to the context menu you then also specify the command that the option uses. The
IsAvailable methods will then get called automatically when the selection changes (regardless of context) and should return
true if the command is available / enabled based on that selection of items.
The context menu option will then hide itself (if
false) or disable itself (if
false) -- or the opposite, depending on your code. When the user clicks on the context menu option, the
Execute method will be called on your command. You can then do whatever it is you wish to do on that selection of items.