Is it possible to get the legend in a pagelayout to only show patches/swatches for features fall within the visible extent of the Map?
The solution needs to work on FeatureLayers and ArcGIS Server layer. It's possible to set a property on the AutoVisibility to filter the Legend to only show the layers that are visible, but if the layer is visible and only a few of multiple symbols in the renderers is visible the legend gets too many items to be useful.
Update: This seems to be a question that has been asked several times before on the ESRI-forum, found one solution that seems to works on a FeatureLayer if it has a IUniqueValueRenderer Compressing a legend to show displayed features only but we are using both FeatureLayer and ArcGIS Server layers, so that only solves part of our problem.
We are trying to find a way to hide and show the IElement from ILegendItem.Graphics , but it feel like a deadend.
On the server ILegendItem.Layer it might be possible to cast to a MapServerIdentifySublayer and use
Identify to somehow find the visible objects.
If that's possible its only a matter of connecting the two.