You have to hook up an handler to the legend Refreshed event and in this handler you can add/remove/change any items in the legend tree (from a layerItem, you can get the LayerItems children and so on if it's a group layer)
if (removeLayerItemVM != null) e.LayerItem.LayerItems.Remove(removeLayerItemVM);
private void Legend_Refreshed(object sender, Legend.RefreshedEventArgs e) { if (e.LayerItem.Layer.ID == "MyFeatureLayer") // could be a test on old label, layer type, url, ... e.LayerItem.Label = "MyAlias"; }
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.