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
1060
Recursive Binding
posted

Hello

Heres my data:

 

Person p = new Person()

            {

                Name = "Fred",

                Friends = new ObservableCollection<Person>

                    {

                        new Person

                            {

                                Name="John",

                                Friends=new ObservableCollection<Person>

                                    {

                                        new Person{Name = "Paul"},

                                        new Person{Name = "Ringo"}

                                    }

                            },

                        new Person

                            {

                                Name="Alan",

                                Friends=new ObservableCollection<Person>

                                    {

                                        new Person{Name = "Jane",

                                            Friends=new ObservableCollection<Person>

                                                {

                                                    new Person{Name = "Harry"},

                                                    new Person{Name = "Gordon"}

                                                }

                                        },

                                       new Person{Name = "Julie"}

                                    }

                            },

                }

            };

 

 

Now, if  I use a Microsoft Treeview with this template :

 

             xmlns:windows="clr-namespace:System.Windows;assembly=System.Windows.Controls"    

 

 

 

        <windows:HierarchicalDataTemplate x:Name="template12"

                                       ItemsSource="{Binding Friends}">

            <StackPanel>

                <TextBlock Text="{Binding Path=Name}" />

            </StackPanel>

        </windows:HierarchicalDataTemplate>

 

 

I get this :

But, if i use the the xamWebTree with this template:

 

        <ig:HierarchicalDataTemplate x:Name="template1"

                                     ItemsSource="{Binding Friends}">

            <ig:HierarchicalDataTemplate.ItemTemplate>

                <DataTemplate>

                    <StackPanel>

                        <TextBlock Text="{Binding Name}" />

                    </StackPanel>

                </DataTemplate>

            </ig:HierarchicalDataTemplate.ItemTemplate>

            <DataTemplate>

                <StackPanel>

                    <TextBlock Text="{Binding Name}" />

                </StackPanel>

            </DataTemplate>

        </ig:HierarchicalDataTemplate>

 

 

I get this :

Why doesn't the xamWebTree implement the n-level recursive binding in the same way the Microsoft Teeview does?  What can I do to achieve this with the xamWebTree?

Thanks

Kevin

 

  • 255
    posted

    hey, Kevin, I think you can do it kind of the same way, like this:

    <igTree:XamWebTree x:Name="dataTree" ItemsSource="{Binding Items}"  >
                                <igTree:XamWebTree.HierarchicalItemTemplate>
                                    <ig:HierarchicalDataTemplate ItemsSource="{Binding SubItems}">
                                        <ig:HierarchicalDataTemplate.ItemTemplate>
                                            <DataTemplate>
                                                <StackPanel Orientation="Horizontal">
                                                    <Image x:Name="myImage" Source="{Binding Image}" Margin="2"  Height="12" Width="12" VerticalAlignment="Center"  />
                                                    <TextBlock x:Name="myText" Text="{Binding Name}"  VerticalAlignment="Center"  />
                                                </StackPanel>
                                            </DataTemplate>
                                        </ig:HierarchicalDataTemplate.ItemTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal">
                                                <Image x:Name="myImage" Source="{Binding Image}"  Margin="2" Height="12" Width="12" VerticalAlignment="Center"  />
                                                <TextBlock x:Name="myText" Text="{Binding Name}"  VerticalAlignment="Center"  />
                                            </StackPanel>
                                        </DataTemplate>
                                    </ig:HierarchicalDataTemplate>
                                </igTree:XamWebTree.HierarchicalItemTemplate>
                            </igTree:XamWebTree>

    Hope it works.

    Paúl.

  • 255
    posted

    hey, Kevin, I think you can do it kind of the same way, like this:

    <igTree:XamWebTree x:Name="dataTree" ItemsSource="{Binding Items}"  >
                                <igTree:XamWebTree.HierarchicalItemTemplate>
                                    <ig:HierarchicalDataTemplate ItemsSource="{Binding SubItems}">
                                        <ig:HierarchicalDataTemplate.ItemTemplate>
                                            <DataTemplate>
                                                <StackPanel Orientation="Horizontal">
                                                    <Image x:Name="myImage" Source="{Binding Image}" Margin="2"  Height="12" Width="12" VerticalAlignment="Center"  />
                                                    <TextBlock x:Name="myText" Text="{Binding Name}"  VerticalAlignment="Center"  />
                                                </StackPanel>
                                            </DataTemplate>
                                        </ig:HierarchicalDataTemplate.ItemTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal">
                                                <Image x:Name="myImage" Source="{Binding Image}"  Margin="2" Height="12" Width="12" VerticalAlignment="Center"  />
                                                <TextBlock x:Name="myText" Text="{Binding Name}"  VerticalAlignment="Center"  />
                                            </StackPanel>
                                        </DataTemplate>
                                    </ig:HierarchicalDataTemplate>
                                </igTree:XamWebTree.HierarchicalItemTemplate>
                            </igTree:XamWebTree>

    Hope it works.

    Paúl.