Select to view content in your preferred language

Legend Control stop to refresh

734
4
03-24-2011 10:52 AM
AlexanderKhoroshun
Deactivated User
I'm wondering if there's any way I can stop Legend Control to refresh?
0 Kudos
4 Replies
DominiqueBroux
Esri Frequent Contributor
There are two kinds of refresh and I am not sure which one you are talking about:
    1) Refresh visibility of legend items : If ShowOnlyVisibleLayers is set to true, the item visibilities may change when zooming. To avoid this kind of refresh you can set ShowOnlyVisibleLayers to false.
    2) Refresh when the legend of a layer changed (which is raising the event 'Refreshed'). This happens mainly when the layer is initializing (i.e. once) and then this happens when the legend of the layer changed.
There is no easy way to stop this kind of refresh but note that the first refresh is mandatory (else no legend items) and then the refresh events are very unfrequent (e.g the legend of an ArcGISDynamicMapServciceLayer never changes and  the legend of a feature layer changes only if one modifies the renderer).

What is your use case for stopping the legend to refresh?
0 Kudos
AlexanderKhoroshun
Deactivated User
Hi Dominique,

Thank you for the response.
The reason why I'm asking how to stop legend refresh is that Lagend control refreshes not only in these two cases.
I have 'Navigation' toolbar in my application and I'm using Draw object for 'Zoom-In' tool to draw rectangle. There are several another tools which use different Draw objects.
When I changed something in Legend control (expanded some layers/sublayers, changed visibility, etc.) and then clicking some tool in toolbar it causes Legend control to refresh and I'm loosing all changes I did in TOC.
I did some reasearch and found that Legend refresh happens when I'm changing some Draw object's properties in my code (for exaample, if I'm switching _myDrawObject.IsEnabled from true to false).

It looks for me like a third  kind of refresh... and I have to find some way how to prevent this type of refresh.

Thanks,

Alexander.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Ahh, yes I see.

It's because some tools can add internal layers so the legend is refreshed since this layer is added to the legend.

AFAIK these internal layers will no more be visible from version 2.2. If you have the opportunity to test with 2.2, let us know the result.

One workaround might be to set the LayerIds property with all the layers of your map. This will exclude the internal layers.

That being said, it's not normal that you loose the changes you did in the TOC.
If you changed the visibility of a layer in the TOC, you should get the same visibility after closing and reopening the legend.
Same thing for the legend expansion. There is a property IsExpanded which should not be lost.

Did you retemplate the legend control? How does your template look?
0 Kudos
AlexanderKhoroshun
Deactivated User
Dominique,

Thanks again! You are right, I don't have this problem when I'm testing our app. with version 2.2 beta.
Do you have any idea when we may get version 2.2?

Alexander.
0 Kudos