I was attempting to keep a copy of the legend item and readd it but it seems like it will be overly complicated for multiple layers.
Could you give an example of the binding the layer property to the checkbox?
Thanks!
The easiest way to get a layer out of the legend is to set the layer.ShowLegend property to false.
So by binding this layer property to your checkbox, you should directly get the expected behavior.
Else, if for any reason you'd rather using the Legend_Refreshed Handler, a couple of possible options:
- call Refresh on the Legend object (the drawback is that all legend layers will be refreshed)
- keep the legend item in a private field when you removed it, so you can readd it when needed.
Hey Dominique,
I can successfully remove a legend entry with your example above. How would I go about re-adding an item after removing it? Once I remove the LayerItem from the Legend l no longer have access to that layer to use the insert method.
Ex:
if(HPGasLegend == false){
if (layerItemVM.Layer.ID == "HP_Gas_Feeder_Layer")
{
Legend.LayerItems.Remove(e.LayerItem);
}
else
// here is where I would like to reinsert the layer above that I removed based on a checkbox checked/unchecked event
// when I hover over the legend object and look through the collection I no longer see my layer that with the ID of "HP_Gas_Feeder_Layer"
// in the collection
Thanks for any help!
I have added the ability to dynamically add an ArcGISDynamicLayer Map Service to the map and to the TOC/Legend. But, it places it at the bottom of the legend, and I would like to place it at the top.
private void Legend_Refreshed(object sender, Client.Toolkit.Legend.RefreshedEventArgs e) { foreach (var bingLayerItem in MyLegend.LayerItems.Where(item => item.Layer is TileLayer).ToList()) MyLegend.LayerItems.Remove(bingLayerItem); }
Is there a way to remove the Bing basemap from the Legend? I tried using the same code as the GraphicsLayer, but it just doesn't see it.
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.