Select to view content in your preferred language

Problem with visibility of layers in legend

2283
3
02-10-2014 03:28 AM
AnatoliiTerentiev
Deactivated User
Dear Gurus!
I began working with the API and ran into a problem. In ESRIStandardMapApplication I replaced topo layer with my own topo layer. And visibility of the layers when run the program does not match the visibility of layers in the map , which I publish. How to fix the problem?
P.S. Switching visibility of layers with the help of checkboxes in the legend tree work normally after that.

xaml:
            <esri:Legend x:Name="Legend" Map="{Binding ElementName=Map}" ShowOnlyVisibleLayers="False" Refreshed="Legend_Refreshed" LayerItemsMode="Tree" Style="{StaticResource LegendStyle1}" LayerTemplate="{StaticResource My_LayerTemplate}" />

In Legend_Refreshed I only work with expanded property.
0 Kudos
3 Replies
AnatoliiTerentiev
Deactivated User
P.S. In  ArcGIS REST Services Directory all  published raster layers has -
Default Visibility: true
0 Kudos
AnatoliiTerentiev
Deactivated User
I thought that the visibility of the property associated with Layer.Visible map layer, but it turned out that it is associated with the property layerItemVM.IsEnabled. I solved the problem by replacing

[HTML]<CheckBox Content="{Binding Label}" IsChecked="{Binding IsEnabled, Mode=TwoWay}"/>[/HTML]
on this
[HTML]<CheckBox Content="{Binding Label}" IsChecked="{Binding Layer.Visible, Mode=TwoWay}"/>[/HTML]
in LayerItemTemplate:
[HTML]<DataTemplate x:Key="My_LayerTemplate">
  <StackPanel Orientation="Horizontal">
     <CheckBox Content="{Binding Label}" IsChecked="{Binding IsEnabled, Mode=TwoWay}"/>
  </StackPanel>
</DataTemplate>[/HTML]

Can't anybody say where I can read about how layerItemVM.IsEnabled formed from the map layers properties?
0 Kudos
DominiqueBroux
Esri Frequent Contributor

Can't anybody say where I can read about how layerItemVM.IsEnabled formed from the map layers properties?


For a layer, layerItemVM.IsEnabled represents the layer.Visible property so "{Binding IsEnabled, Mode=TwoWay}" should be equivalent to "{Binding Layer.Visible, Mode=TwoWay}" for the layers.
However layerItemVM.IsEnabled is more generic since it can manage the sublayer visibility as well (for the layer that supports changing the sublayer visibilities such as a non cached ArcGISDynamicMapServiceLayer).

In case your layer doesn't support changing sublayer visibilities (e.g an ArcGISTiledMapServiceLayer), changing layerItemVM.IsEnabled has no effect while changing Layer.Visible toggles the whole  layer visibility i.e the visibility of all sublayers.
0 Kudos