I´m looking for the best way to create a table of contents for a DynamicMapServiceLayer. I´d like to be able to toggle visibility independently for each sub-layer within this DynamicMapServiceLayer, not just for the entire DynamicMapServiceLayer. All examples I found, and also the "Legend"-class in the Toolkit, seem to operate on the ServiceLayer-level.
Is there any sample code for this? Or is it best to start from scratch?