Select to view content in your preferred language

Omit layers from layer list.

537
1
03-07-2011 07:37 AM
JayKappy
Frequent Contributor
I have a bunch of TiledMapServiceaLayers, WMSLayers, Graphic layers etc.
I have a layer list that is showing each of them and it has a visablility slider...
Everything is great...

But I want to hide a few of them...I dont want the user to be able to turn on and off specific layers, as I am doing this with code...

What would be the best way to control exactly which mapservices will actually show up in the layer list?
Can I even do this?

                             <ListBox x:Name="MyList2" Height="Auto" ItemsSource="{Binding ElementName=MyMap, Path=Layers}" MouseLeave="ButtonHideLayerList">
                                 <ListBox.ItemTemplate>
                                     <DataTemplate>
                                          <StackPanel Orientation="Horizontal">
                                               <CheckBox IsChecked="{Binding Visible, Mode=TwoWay}" />
                                               <Slider Margin="-5,0,0,0" Minimum="0" Maximum="2" Width="30" 
                                                       Value="{Binding Opacity, Mode=TwoWay}" Height="18" />
                                               <TextBlock Text="{Binding ID, Mode=OneWay}" Margin="5,0,0,0" >    
                                                    <ToolTipService.ToolTip>
                                                          <StackPanel MaxWidth="400">
                                                               <TextBlock FontWeight="Bold" Text="HUH" TextWrapping="Wrap" />
                                                               <TextBlock Text="WOW" TextWrapping="Wrap" />
                                                          </StackPanel>
                                                     </ToolTipService.ToolTip>
                                               </TextBlock>
                                           </StackPanel>
                                       </DataTemplate>
                                   </ListBox.ItemTemplate>
                               </ListBox>
0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor
You need to change this property:
ItemsSource="{Binding ElementName=MyMap, Path=Layers}"


The above code will take all layers in your map. If you need to exclude some, you can create your own LayerCollection that only includes layers which Visibility you want to control and use this as your ListBox.ItemsSource instead.
0 Kudos