How to make Legend control refresh the info?

2036
3
Jump to solution
02-21-2013 12:47 PM
Labels (1)
GeorgeFaraj
Occasional Contributor III
How can I make the Legend control refresh the label / image if I change the DisplayName and Renderer properties for a Layer? I've been able to do it by setting the Map to null, then setting it back again. But this resets the tree back to everything expanded. I just want it to update the info. Is this possible?
0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor

The workaround for now might be you to set the Label of the corresponding LayerItemViewModel when you change the DisplayName.


An easier workaround might also be to set ShowLegend to false and then again to true after changing the DisplayName.
layer.DisplayName= "newDisplayName"; layer.ShowLegend=false; layer.ShowLegend=true;

View solution in original post

0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor
The legend is supposed to refresh itself automatically when a property of the layers changes.
However I noticed a bug: when changing the 'DisplayName', the legend is not refreshed.

The workaround for now might be you to set the Label of the corresponding LayerItemViewModel when you change the DisplayName.

We'll try to get it fixed in the API ASAP.

Concerning the renderer, I was not able to reproduce the issue. When changing the layer renderer, the legend seems to refresh (if you found out a use case where that doesn't happen,  a workaround might to call Legend.Refresh()).

Thanks for reporting that.
0 Kudos
DominiqueBroux
Esri Frequent Contributor

The workaround for now might be you to set the Label of the corresponding LayerItemViewModel when you change the DisplayName.


An easier workaround might also be to set ShowLegend to false and then again to true after changing the DisplayName.
layer.DisplayName= "newDisplayName"; layer.ShowLegend=false; layer.ShowLegend=true;
0 Kudos
GeorgeFaraj
Occasional Contributor III
Thank you, Dominique, that workaround worked. I haven't tried changing the renderer yet, but I figured since the name didn't change, I might have problems with the renderer too. Glad that you could find the cause of the bug.

Thanks,
George
0 Kudos