Select to view content in your preferred language

How to show Group Layers..?

839
2
07-30-2010 06:50 AM
JoshV
by
Regular Contributor
Is there a way to show group layers in a tree view in Silverlight 3.0?  In the sample code below it will show the group layer names but it's just a vertical list of check boxes instead of a tree view.

Regards,

<Border Background="#CC5C90B2" BorderThickness="1" CornerRadius="5"
                HorizontalAlignment="Left"  VerticalAlignment="Top"
                Margin="20,20,20,30" Padding="10" BorderBrush="Black">
            <Border.Effect>
                <DropShadowEffect/>
            </Border.Effect>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="15" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <TextBlock Text="Layers in Test Service" FontWeight="Bold" Grid.Row="0" />
                <ListBox Margin="0,5,0,0" ItemsSource="{Binding ElementName=MyMap, Path=Layers.[1].Layers}" 
                         Grid.Row="1">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <CheckBox Margin="2" 
                                  Name="DynamicLayerCalifornia"
                                  Content="{Binding Name}" 
                                  IsChecked="{Binding DefaultVisibility}" 
                                  Tag="{Binding ID}"
                                  ClickMode="Press" 
                                  Click="CheckBox_Click" />
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </Grid>
        </Border>
0 Kudos
2 Replies
AliMirzabeigi
Emerging Contributor
Please take a look at the following links to see how you can use hierarchical data bindings in a tree view control:
http://blogs.silverlight.net/blogs/justinangel/archive/2008/11/18/silverlight-toolkit-treeview-treev...
http://geekswithblogs.net/tkokke/archive/2009/06/29/styling-a-treeview-in-silverlight-and-blend-3.as...

And for data bindings, you should use {Binding ElementName=MyMap, Path=Layers} for the root node(s) and {Binding ElementName=MyMap, Path=Layers.[1].Layers} for your group layer.

Hope this helps.
0 Kudos
JoshV
by
Regular Contributor
Please take a look at the following links to see how you can use hierarchical data bindings in a tree view control:
http://blogs.silverlight.net/blogs/justinangel/archive/2008/11/18/silverlight-toolkit-treeview-treev...
http://geekswithblogs.net/tkokke/archive/2009/06/29/styling-a-treeview-in-silverlight-and-blend-3.as...

And for data bindings, you should use {Binding ElementName=MyMap, Path=Layers} for the root node(s) and {Binding ElementName=MyMap, Path=Layers.[1].Layers} for your group layer.

Hope this helps.


Hi Ali-  Any chance I can create/add this tree view using just Visual Studio?  This looks promising.

Regards,
-Josh
0 Kudos