Select to view content in your preferred language

How to collapse the map service node in Legend by default?

2377
2
11-16-2011 06:22 AM
SanajyJadhav
Deactivated User
Hello,

I am following online sample 'Legend' to create my TOC.The problem is when my apps loads, all map service nodes in the Legend tree structure are in expanded state by default.

I went throguh the another sample Legend with Templates which shows one map service as collapsed and other as expanded.But, I am not being able to figure out, what has to be to do this? I want my all map service nodes in collapsed form by default.

Can anybody please help me on this? Help would be appreciated.
0 Kudos
2 Replies
MichaelKohler
Frequent Contributor
Add a legend refreshed event handler to your legend.


<esri:Legend Map="{Binding ElementName=MyMap}" 
                    ............
                    Refreshed="Legend_Refreshed"
                    ............


In the code behind put this...

private void Legend_Refreshed(object sender, Legend.RefreshedEventArgs e)
{
     e.LayerItem.IsExpanded = false;
}
0 Kudos
SanajyJadhav
Deactivated User
That worked great! Thanks a lot.
0 Kudos