Select to view content in your preferred language

Legend with Template example does not work with LayerItemsMode = "Tree"

3499
8
02-02-2011 10:31 AM
LenKne
by
Emerging Contributor
Hi All

I've taken the example from here
http://help.arcgis.com/en/webapi/silverlight/2.1/samples/start.htm#LegendWithTemplates
to build a legend.  The only change made to the xaml is to set LayerIDs to match the services I am using. 

If I set LayerItemsMode = "Flat", it works great.  If I set  LayerItemsMode = "Tree", the checkbox, service name and slider appear for each layer.  What is not rendered are the legend graphics or the triangle images to expand the layers.  Environment is ArcGIS Server 10 SP1.

Any ideas on what to look for to troubleshoot this issue?

Thanks

Len
0 Kudos
8 Replies
DominiqueBroux
Esri Frequent Contributor
The sample you mentionned is using LayerItemsMode = "Tree" and is working well.
So there is something specific to your tempalte or your data.
Could you share your legend template and a screenshot of the result?
0 Kudos
LenKne
by
Emerging Contributor
Hi Dominique

Thanks for taking a look at this.  Here is map and legend template and attached is a screen shot.

       <esri:Map x:Name="map"  Extent="389600.930034305,4913907.87640152,564886.371836438,5039325.78714151" SnapToLevels="True" Margin="0,70,0,10" MouseClick="QueryPointMouseClick">
            <esri:ArcGISTiledMapServiceLayer ID="BaseLayer"   
                     Url="http://gis.metc.state.mn.us/ArcGIS/rest/services/BaseLayer/UTMBaseMap/MapServer/" Visible="True"/>
            <esriData:WmsLayer ID="Image" Url="http://geoint.lmic.state.mn.us/cgi-bin/wms" SkipGetCapabilities="False" Version="1.3.0" Layers="met10" Visible="False"  />
            <esri:ArcGISDynamicMapServiceLayer ID="Network Services"
                     Url="http://localhost/ArcGIS/rest/services/NetworkTraceService/MapServer/" />
            <esri:ArcGISDynamicMapServiceLayer ID="Parks" Visible="False"
                     Url="http://localhost/ArcGIS/rest/services/parks/MapServer/" />
            <esri:GraphicsLayer ID="MyGraphicsLayer" />
        </esri:Map>

        <Border Background="#77919191" BorderThickness="1" CornerRadius="5"
            HorizontalAlignment="Right"  VerticalAlignment="Top"
            Margin="20" Padding="5" BorderBrush="Black" >
            <esri:Legend Map="{Binding ElementName=map}" 
                         LayerIDs="Network Services"
                         LayerItemsMode="Tree"
                         ShowOnlyVisibleLayers="False"
                         Refreshed="Legend_Refreshed">
                <esri:Legend.MapLayerTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <CheckBox Content="{Binding Label}"
                  IsChecked="{Binding IsEnabled, Mode=TwoWay}"
                  IsEnabled="{Binding IsInScaleRange}" >
                            </CheckBox>
                            <Slider Maximum="1" Value="{Binding Layer.Opacity, Mode=TwoWay}" Width="50" />
                        </StackPanel>
                    </DataTemplate>
                </esri:Legend.MapLayerTemplate>
                <esri:Legend.LayerTemplate>
                    <DataTemplate>
                        <CheckBox Content="{Binding Label}"
                   IsChecked="{Binding IsEnabled, Mode=TwoWay}"
                IsEnabled="{Binding IsInScaleRange}" >
                        </CheckBox>
                    </DataTemplate>
                </esri:Legend.LayerTemplate>
            </esri:Legend>
        </Border>

The control is in the upper right-hand corner of the map.

Len
0 Kudos
DominiqueBroux
Esri Frequent Contributor
From the screenshot, it might be that your server has not been updated to 10SP1 and so, the legend service is not available (furthermore, in your case, the arcgis.com fallback mechanism is not available because your service is not public).

Please check by querying http://localhost/ArcGIS/rest/services, if you are in 10SP1, you should see Version=10.01 .
0 Kudos
LenKne
by
Emerging Contributor
I checked the server version and it is 10.01. What's strange is if I change LayerItemsMode="Flat", the legend shows up fine (see attached screen shot).  What's missing when it is flat, that would be available with a tree is a the ability to collapse the layers.  Seems like it has to be on the Silverlight side, but I am not sure where the issue would be.

Len
0 Kudos
DominiqueBroux
Esri Frequent Contributor
hummm, verify that there is no default legend style defined somewhere in your application (most likely in app.xaml).

If it's the case, remove this default legend style.
0 Kudos
LenKne
by
Emerging Contributor
Dominique, thanks a lot!  There was a legend style in app.xaml, once that was removed, legend works great. 

Len
0 Kudos
DarinaTchountcheva
Frequent Contributor
Dominique,

Thank you so much! You saved my sanity! 😄

Darina
0 Kudos
PLadd
by
Frequent Contributor
thanks db:cool:
0 Kudos