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 do1. 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.
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.
string url = theUserUrl; ArcGISDynamicMapServiceLayer layer = new ArcGISDynamicMapServiceLayer {Url = the UserUrl }; // this might be ArcGISTiledMapServiceLayer depending on the service type MyMap.Layers.Add(layer);
<esri:Legend Map="{Binding ElementName=MyMap}"
<Windows:HierarchicalDataTemplate x:Key="GroupTemplate" ItemTemplate="{StaticResource LayerTemplate}" ItemsSource="{Binding Path=MapGroups}"> <StackPanel Orientation="Vertical"> <StackPanel Orientation="Horizontal" MouseRightButtonDown="StackPanelMouseRightButtonDown" Margin="10,0,10,0" > <CheckBox IsTabStop="False" IsThreeState="False" IsChecked="{Binding IsVisible, Mode=TwoWay}" Commands:Click.Command="{Binding TreeNodeClickCommand}" Margin="5,0,5,0" Commands:Click.CommandParameter="{Binding ElementName=TreeViewControl, Path=SelectedItem}" Click="CheckBoxClick" VerticalAlignment="Center"/> <TextBlock Text="{Binding Path=Name}" Width="120" Margin="0" VerticalAlignment="Center"/> <Slider Minimum="0" Maximum="1" Width="100" Margin="10,0,10,0" Value="{Binding Opacity, Mode=TwoWay}" Infrastructure:SliderValueChange.Command="{Binding OpacityChangeCommand}"/> </StackPanel> </StackPanel> </Windows:HierarchicalDataTemplate>
<Controls:TreeView x:Name="TreeViewControl" Background="{StaticResource MainPageBackgroundBrush}" ItemTemplate="{StaticResource GroupTemplate}" ItemsSource="{Binding MapServiceLayers, Mode=TwoWay}" FlowDirection="{Binding FlowDirection, Mode=TwoWay}" />
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.