Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
4970
How to set different icon for nodes at different level for xamtree?
posted

I tried to create a XamTree with following xaml:

  <UserControl.Resources>
        <DataTemplate x:Key="ExpandedIcon">
            <Grid>
                <Image Source="open.png" Height="35" Width="24"/>
            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="CollapsedIcon">
            <Grid>
                <Image Source="close.png" Height="35" Width="24"/>
            </Grid>
        </DataTemplate>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White"  HorizontalAlignment="Stretch">
            <ig:XamTree ExpandedIconTemplate="{StaticResource ExpandedIcon}" CollapsedIconTemplate="{StaticResource CollapsedIcon}" >
            <ig:XamTree.HierarchicalItemTemplate>               
                    <ig:HierarchicalDataTemplate ItemsSource="{Binding Children}">
                        <ig:HierarchicalDataTemplate.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding Name}" Foreground="Gray" />
                                </StackPanel>
                            </DataTemplate>                           
                        </ig:HierarchicalDataTemplate.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Name}" FontWeight="Bold"/>
                            </StackPanel>
                        </DataTemplate>
                    </ig:HierarchicalDataTemplate>
                </ig:XamTree.HierarchicalItemTemplate>
            </ig:XamTree>
        </Grid>

Data is loaded from database.  with about code, all tree nodes have same icon. I want to different level nodes have different icon. How to resolve this issue?

 

 

Parents
No Data
Reply Children
No Data