Databound Legend and checkbox

975
3
09-29-2011 04:43 AM
BonnieGolla
New Contributor
I have a map with many layers and I am using a databound legend with the checkbox, code as follows.

  <esri:Legend x:Name="BaseMapLegend" Map="{Binding ElementName=MyMap}" 
          Loaded="BaseMapLegend_Loaded" HorizontalContentAlignment="Left"
  HorizontalAlignment="Left" ShowOnlyVisibleLayers="False" LayerItemsMode="Tree"                Refreshed="BaseMapLegend_Refreshed" Width="auto">
<esri:Legend.MapLayerTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <CheckBox x:Name="chkBaseMapLegend" Content="{Binding Label}" 
                                                      IsChecked="{Binding IsEnabled, Mode=TwoWay}"
                                                      IsEnabled="{Binding IsInScaleRange}">
                                            </CheckBox>
                                            <Slider Maximum="1" Value="{Binding Layer.Opacity, Mode=TwoWay}" Width="40" />
                                        </StackPanel>
                                    </DataTemplate>
                                </esri:Legend.MapLayerTemplate>
                            </esri:Legend>

I would like the legend to load with the checkboxes unchecked and the layers not appearing on the map.  The default for the databound legend is that the layers load checked and all layers appear on the map via "IsChecked="{Binding IsEnabled, Mode=TwoWay}".  Does anyone know how this can be done?  I am working in VB in Visual Studio 2010 with ArcGIS 10 and Silverlight 4.0.

Thanks in advance for any help anyone can provide!
0 Kudos
3 Replies
BrandonCopeland
New Contributor
How are the Layers created? Can you just set Visible = false (or xaml <Layer Visible=false />) at that time?
0 Kudos
BonnieGolla
New Contributor
That works.  I was so focused on doing it through the legend that I didn't look at something so obvious.  Thank you!
0 Kudos
MohammadSharique
New Contributor
Hi,
My issue also same kindly explain me in detail how i can set visibility false in xmal.

Thanks in Advance
Mohammad Sharique Shaikh
0 Kudos