I have SP1 installed for ArcGISServer 10 and am using the Legend tool from the toolkit in Tree mode with a template to group the sublayers on an ArcGISDynamicMapServiceLayer. I'm assigning the LayerIDs to keep the Graphics Layer from being listed in the Legend. The legend displays correctly and if I check or uncheck a checkbox on a layer that has no sublayers, it works correctly. If, however, I uncheck on a group layer that has sublayers, the entire map goes blank. If I recheck the group layer, the entire map comes back. The behaviour should be to turn off just the group related layers and I'm unsure what is causing this. I think my configuration is quite basic. Any help would be appreciated.XAML <esri:Legend x:Name="myLegend" Map="{Binding ElementName=map}" LayerItemsMode="Tree" ShowOnlyVisibleLayers="False" Refreshed="myLegend_Refreshed">
<esri:Legend.LayerTemplate>
<DataTemplate>
<CheckBox Content="{Binding Label}"
IsChecked="{Binding IsEnabled, Mode=TwoWay}"
IsEnabled="{Binding IsInScaleRange}" >
</CheckBox>
</DataTemplate>
</esri:Legend.LayerTemplate>
</esri:Legend>
Code Behind C#
private string[] layerList = { "Utilities" };
public LegendControl()
{
// Required to initialize variables
InitializeComponent();
this.Loaded += new RoutedEventHandler(LegendControl_Loaded);
}
void LegendControl_Loaded(object sender, RoutedEventArgs e)
{
this.myLegend.Map = map;
this.legend.LayerIDs = layerList;
this.legend.Refresh();
}
private void myLegend_Refreshed(object sender, Legend.RefreshedEventArgs e)
{
if (e.LayerItem.LayerItems != null)
{
foreach (LayerItemViewModel layerItemVM in e.LayerItem.LayerItems)
{
if (layerItemVM.IsExpanded)
layerItemVM.IsExpanded = false;
if (layerItemVM.LayerItems != null)
foreach (LayerItemViewModel sublayerItemVM in layerItemVM.LayerItems)
if (sublayerItemVM.IsExpanded)
sublayerItemVM.IsExpanded = false;
}
}
else
{
e.LayerItem.IsExpanded = false;
}
}