POST
|
Many thanks Joe. I'll give it a bash and let you know how I get on. Just looking at the code you've provided, it is apparent it does what I want. It's just my inability to grasp the silverlight concept that is making me unable to do what I want to do... In this light I shall mark your answer as the right answer. If I manage to put something that works together I shall post that here as well for the benefit of others. Many thanks blueRace
... View more
06-05-2012
01:11 PM
|
0
|
0
|
440
|
POST
|
Many thanks Joe for the tips, code and advice. I really appreciate it. I thought by picking a "project" I would grasp the concepts quicker but this is proving elusive with silverlight for me. Any way will keep at it. Just so we are on the same page, and for the benefits of other who may or may not be in the same predicament as me this is what I am looking to do 1. User enters a URL to a Map service, (see link above) - Currently this sample works for Tiled services - Looking to eventually extend this so service type doesn't matter. 2. With no map displayed on the map canvas yet, the sub-layers, if any, would be listed - in a folder or tree fashion. 3. User selects a sub-layer, and can at this point add it to or display it on the map canvas. And at this point it can be added to the legend control.
... View more
06-03-2012
03:13 PM
|
0
|
0
|
440
|
POST
|
Many thanks for the reply Joe. However I'm still lost. How is this implemented? When a users enters a URL how would and it's initialized and added to the map in the code behind, how is this then passed to the various elements in the XAML? Really struglling with getting the concept of linking elements from the C# code behind and the XAML elements. Any further help would be very much appreciated.
... View more
06-03-2012
05:37 AM
|
0
|
0
|
440
|
POST
|
Hi All, This thread subLayers, Listbox and symbology does half of what I'm looking to accomplish. The other half is I am looking not to have the layers hard coded in the XAML I�??m looking to (1) have users enter the URL like here #AddLayerDynamically then (2)the Sublayers (including any hierarchy) would be listed with checkboxs somwhat like here #SubLayerList. This probably means most of the code will be done in codebehind c# then bound to respective elements in the XAML I�??m very new to Silverlight. I�??ve been trying to do this for ages but no joy. Any help would be very much appreciated.
... View more
06-01-2012
12:09 PM
|
1
|
6
|
2394
|
POST
|
Hi I�??m hoping this thread is still open. I am looking to do something similar to what has been discussed here but my twist is instead of having the layers hard coded in the XAML I�??m looking to (1) have users enter the URL like here #AddLayerDynamically then (2)the Sublayers (including any hierarchy) would be listed with checkboxs like here #SubLayerList. This probably means most of the code will be done in codebehind c# then bound to respective elements in the XAML I�??m very new to Silverlight. I�??ve been trying to do this for ages but no joy. Any help would be very much appreciated.
... View more
06-01-2012
11:56 AM
|
0
|
0
|
202
|
POST
|
Hi I�??m hoping this thread is still open. I am looking to do something similar to what has been discussed here but my twist is instead of having the layers hard coded in the XAML I�??m looking to (1) have users enter the URL like here #AddLayerDynamically then (2)the Sublayers (including any hierarchy) would be listed with checkboxs like here #SubLayerList. This probably means most of the code will be done in codebehind c# then bound to respective elements in the XAML I�??m very new to Silverlight. I�??ve been trying to do this for ages but no joy. Any help would be very much appreciated. Sorry I forgot to mention that if you have a hierarchy of group layers, you have also to adapt the C# code to take into account this hierarchy. Here is the code which should work whatever the number of group levels: void Legend_Refreshed(object sender, ESRI.ArcGIS.Client.Toolkit.Legend.RefreshedEventArgs e)
{
SetLayerItemImageSource(e.LayerItem);
}
private void SetLayerItemImageSource(LayerItemViewModel layerItem)
{
if (layerItem.LegendItems != null && layerItem.LegendItems.Any()) // if there is a legend item
layerItem.ImageSource = layerItem.LegendItems.First().ImageSource; // set the image of the sublayer with the image of the first legenditem
// Call recursively SetLayerItemImageSource
if (layerItem.LayerItems != null)
{
foreach(var sublayerItem in layerItem.LayerItems)
SetLayerItemImageSource(sublayerItem);
}
} Note that instead of using your own listbox and a binding to a legend control, you can also retemplate the legend control to use a listbox. For example with this template: <esri:Legend Map="{Binding ElementName=MyMap}" LayerItemsMode="Flat" ShowOnlyVisibleLayers="False" LayerIDs="California" Refreshed="Legend_Refreshed">
<esri:Legend.Template>
<ControlTemplate TargetType="esri:Legend">
<ListBox ItemsSource="{TemplateBinding LayerItemsSource}" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding IsEnabled, Mode=TwoWay}" IsEnabled="{Binding IsInScaleRange}" VerticalAlignment="Center"/>
<TextBlock Text="{Binding Label}" VerticalAlignment="Center"/>
<Image Source="{Binding ImageSource}" Margin="3,0"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ControlTemplate>
</esri:Legend.Template>
<esri:Legend> you get this result:
... View more
06-01-2012
11:55 AM
|
0
|
0
|
202
|
Title | Kudos | Posted |
---|---|---|
1 | 06-01-2012 12:09 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|