<esri:Map x:Name="MyMap" Background="White" WrapAround="true" IsLogoVisible="False" Loaded="MyMap_Loaded" Extent="959677,402707,1075561,470675" MouseClick="MyMap_MouseClick"> <esri:Map.Layers> <esri:ArcGISTiledMapServiceLayer ID="AGOLayer" Url="http://webaddress"/> <esri:ArcGISDynamicMapServiceLayer ID="Attendance Areas" Opacity=".5" Url="http://webaddress"/> <esri:ArcGISTiledMapServiceLayer ID="Labels" Url="http://webaddress"/> <esri:FeatureLayer ID="Schools" MouseEnter="FeatureLayer_MouseEnter" MouseLeave="FeatureLayer_MouseLeave" Url="webaddress" OutFields="SCHNAME, ADDRESS, PHONE, URL"/> <esri:FeatureLayer ID="Schools Without Attendance Areas" MouseEnter="FeatureLayer_MouseEnter" MouseLeave="FeatureLayer_MouseLeave" Visible="False" Url="http://webaddress" OutFields="SCHNAME, ADDRESS, PHONE, URL"/> <esri:GraphicsLayer ID="ResultsGraphicsLayer"/> <esri:GraphicsLayer ID="MyGraphicsLayer"/> <esri:GraphicsLayer ID="IdentifyIconGraphicsLayer"/> <esri:GraphicsLayer ID="AddressToLocationGraphicsLayer"> <esri:GraphicsLayer.MapTip> <Grid Background="LightYellow"> <StackPanel Margin="5" > <TextBlock Text="{Binding [Address]}" HorizontalAlignment="Left" /> <TextBlock Text="{Binding [LatLon]}" HorizontalAlignment="Left" /> </StackPanel> <Border BorderBrush="Black" BorderThickness="1" /> </Grid> </esri:GraphicsLayer.MapTip> </esri:GraphicsLayer> </esri:Map.Layers> </esri:Map> <Style TargetType="esri:Legend"> <Setter Property="LayerItemsMode" Value="Flat" /> <Setter Property="LayerTemplate"> <Setter.Value> <DataTemplate> <StackPanel Orientation="Horizontal"> <CheckBox Content="{Binding Label}" IsChecked="{Binding IsEnabled, Mode=TwoWay}" IsEnabled="{Binding IsInScaleRange}" > </CheckBox> </StackPanel> </DataTemplate> </Setter.Value> </Setter> <Setter Property="MapLayerTemplate"> <Setter.Value> <DataTemplate> <StackPanel Orientation="Horizontal"> <CheckBox Content="{Binding Label}" IsChecked="{Binding IsEnabled, Mode=TwoWay}" IsEnabled="{Binding IsInScaleRange}" > </CheckBox> </StackPanel> </DataTemplate> </Setter.Value> </Setter> </Style> private void Legend_Refreshed(object sender, Legend.RefreshedEventArgs e) { LayerItemViewModel removeLayerItemVM = null; if (e.LayerItem.Layer is ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer) e.LayerItem.LayerItems = null; if (e.LayerItem.LayerItems != null) { foreach (LayerItemViewModel layerItemVM in e.LayerItem.LayerItems) { if (layerItemVM.IsExpanded) layerItemVM.IsExpanded = false; } if (removeLayerItemVM != null) e.LayerItem.LayerItems.Remove(removeLayerItemVM); } else { e.LayerItem.IsExpanded = false; } }
Solved! Go to Solution.