Select to view content in your preferred language

2.1 Legend LayerItems Description and Copyright Text *SOLVED

944
5
11-18-2010 07:54 AM
RyanCoodey
Frequent Contributor
Sorry for all the posts about the Legend control... I really like the control but just need to work a few things out for the requirments I have :).

1)  The "Description" for a service is not set but the "Description" for the sub-layers is set to that of the services "Description"... this is in the Legend.LayerItems collection which is being bound to in the XAML control... is this a bug?  It seems backward... or am I doing something wrong?
*EDIT* Ok, this is wierd, now all of a sudden the "Description" is set for the services that are coming from our gis server, but not from the ESRI services (Aerial, Topo, Etc)...  If i use Layer.Description my tooltip is fine even on the ESRI services...
*EDIT 2* I must have done something... because I don't have this issue with sublayers having the main services description anymore... not really sure why though.

2) Could you also add the "CopyrightText" to the LayerItemViewModel so I could easily bind to that aswell? 
*EDIT* I can just get this from "Layer.CopyrightText" in the xaml... I was affraid that might cause issues, but it seems fine... so this question is solved for me, thanks!

I like to show the "Description" and "CopyrightText" in the tooltips for the service.

Thanks a lot!

*EDIT 3*
Still not sure why the "Description" is not set on the ESRI services, but I got all my issues worked out... guess I jumped the gun on posting this here.
0 Kudos
5 Replies
DominiqueBroux
Esri Frequent Contributor

Sorry for all the posts about the Legend control...

You are welcome. It's nice to get feedbacks before the final.



I really like the control

Thanks 🙂



I can just get this from "Layer.CopyrightText" in the xaml

Right, but this will only work with ArcGISxxxxxLayer. For other layer types (e.g FeatureLayer) it will be null (fallback value)

Glad you solved your other issues.
0 Kudos
VadimPaz_Gorelov
Emerging Contributor
Hi, hello.

I want to attach to legend the "description" and "copyright" text from layer(0) Map.Layer.

We develop this service:
http://.../server/rest/services/RB/ContaminacionLuminica/MapServer/0

It declared like ArcGISDynamicMapServiceLayer:http://../server/rest/services/RB/ContaminacionLuminica/MapServer

In XAML I made the legend template like this:

        <Style TargetType="esri:Legend">
   <Setter Property="LayerItemsMode" Value="Flat" />
   <Setter Property="Template">
    <Setter.Value>
     <ControlTemplate TargetType="esri:Legend">
      <ScrollViewer Background="{StaticResource BaseColor}" BorderBrush="{TemplateBinding BorderBrush}"
           BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
       <ItemsControl ItemsSource="{TemplateBinding LayerItemsSource}" Foreground="White"
            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}">
        <ItemsControl.ItemTemplate>
         <DataTemplate>
          <StackPanel Orientation="Vertical" Margin="5">
           <!--Layer Item-->
           <!--<ContentPresenter Content="{Binding}" ContentTemplate="{Binding Template}" />-->
                                            <TextBlock Name="legendLabel" Text="{Binding Path=Label}" TextWrapping="Wrap" />
                                            <!--Description-->
                                            <TextBlock Name="legendDescription" Text="{Binding Path=Description}" TextWrapping="Wrap" />
                                            <!--Legend Items-->
           <ItemsControl ItemsSource="{Binding LegendItems}">
            <ItemsControl.ItemTemplate>
                                                    <DataTemplate>
                                                        <ContentPresenter Content="{Binding}" ContentTemplate="{Binding Template}" />
             </DataTemplate>
            </ItemsControl.ItemTemplate>
           </ItemsControl>                                    
                                            <!--Sources-->
                                            <TextBlock Name="legendSource" Text="Source..." TextWrapping="Wrap" />
                                             <HyperlinkButton Name="legendSourceLink" TargetName="_blank"  Content="link Source..." NavigateUri="http://www."/>
                                        </StackPanel>
         </DataTemplate>
        </ItemsControl.ItemTemplate>
        <ItemsPresenter/>
       </ItemsControl>
      </ScrollViewer>
     </ControlTemplate>
    </Setter.Value>
   </Setter>
  </Style>


But i dont know how to binding properties elements for Description and Copyright Text asigned to controls legendDescription and legendSource.

We are trying to develop the very rich interface of legend sources like this:
http://ec.europa.eu/maritimeaffairs/atlas/maritime_atlas/#JoinFishCatches=ZZB&=null&extent=106.9_-29...

Which directiosn we need to review?
0 Kudos
RyanCoodey
Frequent Contributor
vpazmadrid,

I am not doing this in a ControlTemplate like you are, I am doing it in the DataTemplate... so not sure how much this will help you but here is how I bound the Description and CopyrightText:

                            <esri:Legend x:Name="Legend" Grid.Row="1" Background="Transparent" HorizontalContentAlignment="Stretch" BorderThickness="0" LayerItemsMode="Tree" MinWidth="{TemplateBinding MinContentWidth}" ShowOnlyVisibleLayers="False">
                                <esri:Legend.MapLayerTemplate>
                                    <DataTemplate>
                                        <StackPanel Margin="1" Orientation="Horizontal">
                                            <local:GrayableCheckBox IsChecked="{Binding IsEnabled, Mode=TwoWay}" VerticalAlignment="Center" IsGrayed="{Binding IsInScaleRange, Converter={StaticResource InverseBoolConverter}}" ToolTipService.ToolTip="Toggle Service Visibility" />
                                            <TextBlock Text="{Binding Label}" Margin="2,0,0,0" VerticalAlignment="Center">
                                                <ToolTipService.ToolTip>
                                                    <ToolTip>
                                                        <ToolTip.Visibility>
                                                            <PriorityBinding>
                                                                <Binding Path="Layer.Description" Converter="{StaticResource StringVisibilityConverter}" IsAsync="True" Mode="OneWay" />
                                                                <Binding Path="Layer.LayerInfo.Description" Converter="{StaticResource StringVisibilityConverter}" IsAsync="True" Mode="OneWay" />
                                                            </PriorityBinding>
                                                        </ToolTip.Visibility>  
                                                        <StackPanel MaxWidth="400" >
                                                            <TextBlock TextWrapping="Wrap" Margin="1,1,1,6">
                                                                <TextBlock.Text>
                                                                    <PriorityBinding>
                                                                        <Binding Path="Layer.Description" IsAsync="True" Mode="OneWay" />
                                                                        <Binding Path="Layer.LayerInfo.Description" IsAsync="True" Mode="OneWay" />
                                                                    </PriorityBinding>
                                                                </TextBlock.Text>    
                                                            </TextBlock>
                                                            <TextBlock FontWeight="Bold" TextWrapping="Wrap">
                                                                <TextBlock.Text>
                                                                    <PriorityBinding>
                                                                        <Binding Path="Layer.CopyrightText" IsAsync="True" Mode="OneWay" />
                                                                        <Binding Path="Layer.LayerInfo.CopyrightText" IsAsync="True" Mode="OneWay" />
                                                                    </PriorityBinding>
                                                                </TextBlock.Text>    
                                                            </TextBlock>
                                                        </StackPanel>
                                                    </ToolTip>
                                                </ToolTipService.ToolTip>
                                            </TextBlock>
                                            <Image Source="/SDL.ArcGIS.Client.Toolkit;component/Table Of Contents/Images/Time.png" Visibility="{Binding Layer.TimeExtent, Converter={StaticResource TimeExtentVisibilityConverter}, FallbackValue='Collapsed'}" ToolTip="Layer Is Time Aware" Width="12" Height="12" Margin="2,0,0,0" />
                                            <Slider Minimum="0" Maximum="1" Value="{Binding Layer.Opacity, Mode=TwoWay}" Width="60" ToolTipService.ToolTip="Set Layer Transparency" HorizontalAlignment="Right" Margin="2,0,0,0"  />
                                        </StackPanel>
                                    </DataTemplate>
                                </esri:Legend.MapLayerTemplate>


Hope it helps a little.
0 Kudos
VadimPaz_Gorelov
Emerging Contributor
Thx Rcodey..

But I don´t find LayerInfo.Description or LayerInfo.CopyrightText in silverlight api model.

I´m access elemento objects at level: e.LayerItem, this a service level.
And e.LayerItem.LayerItems[0].Label is a layer of the service , all this in code.

But in XAML I think we need to binding properties at service level, but I don´t find description or copyright.

Also I´m trying this one with no luck:
Text="{Binding Path=Map.Layers[Layer.ID].Description}"
Text="{Binding Path=Map.Layers[Layer.ID].CopyrightText}"
0 Kudos
VadimPaz_Gorelov
Emerging Contributor
Oh thanks again ..
Its was so easy but using:
Layer.Description
or
Layer.CopyrightText

But we need to assing these properties to service level.
At layer level, we don´t know how to access description or copyright , for example of raster layer in one dynamic service.
Capa: The World Atlas of the Artificial Night Sky Brightness (Id.: 0)
Campo de visualización:
Tipo: Raster Layer
Tipo de geometría:
Descripción: Ratios between the artificial sky brightness and the natural sky brightness
Expresión de definición:
Texto de copyright: Credit: P. Cinzano, F. Falchi (University of Padova), C. D. Elvidge (NOAA National Geophysical Data Center, Boulder). Copyright Royal Astronomical Society. Reproduced from the Monthly Notices of the RAS by permission of Blackwell Science.



At the moment the high level solution its good, Thank you.
0 Kudos