This is a migrated thread and some comments may be shown as answers.

Partially Bound RadTreeView

3 Answers 103 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 30 Nov 2011, 10:41 PM

I'm attempting (with limited success) to create a TreeView that contains a mixture of dynamic and static data.

You'll find my current best attempt at this below, however since I'm nesting TreeViews there is a side effect wherein it is possible to have multiple items within the parent TreeView selected.  When I've tried nesting TreeViewItems the results were not positive, i.e. only the parent level TreeViewItem in the ItemTemplate is displayed and space for it's children is created but nothing is output.

I would really like to know how to acheive my goal without resorting to specifying the entire menu in collections which I bind to the TreeView.

Thank you

<telerik:RadTreeView Width="225" HorizontalAlignment="Left" Background="Transparent" FontWeight="SemiBold">
            <telerik:RadTreeViewItem Header="Customer" Command="{Binding OpenCustomerCommand}"/>
            <telerik:RadTreeViewItem Header="Sites" Command="{Binding OpenSiteBrowserCommand}" ItemsSource="{Binding Sites}">
  
                <telerik:RadTreeViewItem.ItemTemplate>
                    <DataTemplate>
                              
                        <telerik:RadTreeView>
  
                            <telerik:RadTreeViewItem Header="{Binding Key}"
                                Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=view:WindowViewBase}, 
                                Path=DataContext.OpenSiteCommand}" 
                                CommandParameter="{Binding Value}">
  
                                <telerik:RadTreeViewItem Header="Material Profiles" 
                                    Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=view:WindowViewBase}, 
                                    Path=DataContext.OpenMaterialProfileBrowserCommand}" 
                                    CommandParameter="{Binding Value}"/>
  
                                <telerik:RadTreeViewItem Header="Prices" 
                                    Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=view:WindowViewBase}, 
                                    Path=DataContext.OpenPriceBrowserCommand}" 
                                    CommandParameter="{Binding Value}"/>
  
                                <telerik:RadTreeViewItem Header="Orders"
                                    Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=view:WindowViewBase}, 
                                    Path=DataContext.OpenOrderBrowserCommand}" 
                                    CommandParameter="{Binding Value}"/>
  
                                <telerik:RadTreeViewItem Header="Activity">
  
                                    <telerik:RadTreeViewItem Header="Collection"
                                        Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=view:WindowViewBase}, 
                                        Path=DataContext.OpenActivityCollectionsBrowserCommand}" 
                                        CommandParameter="{Binding Value}"/>
  
                                    <telerik:RadTreeViewItem Header="Call Outs"
                                        Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=view:WindowViewBase}, 
                                        Path=DataContext.OpenActivityCallOutBrowserCommand}" 
                                        CommandParameter="{Binding Value}"/>
  
                                    <telerik:RadTreeViewItem Header="Gate"
                                        Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=view:WindowViewBase}, 
                                        Path=DataContext.OpenActivityGateBrowserCommand}" 
                                        CommandParameter="{Binding Value}"/>
  
                                    <telerik:RadTreeViewItem Header="One Off Charges"
                                        Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=view:WindowViewBase}, 
                                        Path=DataContext.OpenActivityOneOffChargeBrowserCommand}" 
                                        CommandParameter="{Binding Value}"/>
  
                                </telerik:RadTreeViewItem>
  
                            </telerik:RadTreeViewItem>
                        </telerik:RadTreeView>
                    </DataTemplate>
                </telerik:RadTreeViewItem.ItemTemplate>
  
            </telerik:RadTreeViewItem>

3 Answers, 1 is accepted

Sort by
0
Tony
Top achievements
Rank 1
answered on 01 Dec 2011, 01:44 AM

I'm hesitent to cry "bug" before I get a reply here as there may be some subtle differences between the RadTreeView and .Net 4 TreeView.  However please see some XAML below, one example using the .Net TreeView and the other the Telerik RadTreeView.  The .Net version does what I would expect but the Telerik one doesn't.

I would still really like to hear if it it's possible to get both examples here to produce the same results because I would much prefer to use the Telerik controls as they have support for ICommands out of the box.

Working Code (using .Net TreeView):

<TreeView Width="225" BorderBrush="Transparent" HorizontalAlignment="Left" Background="Transparent" FontWeight="SemiBold">
    <TreeViewItem Header="Customer"/> 
    <TreeViewItem Header="Sites" ItemsSource="{Binding Sites}">
        <TreeViewItem.ItemTemplate>
            <DataTemplate>
                <TreeViewItem Header="{Binding Key}">
                    <TreeViewItem Header="Material Profiles"/>
                    <TreeViewItem Header="Prices"/>
                </TreeViewItem>
            </DataTemplate>
        </TreeViewItem.ItemTemplate>
    </TreeViewItem>
</TreeView>

   

Not Working (using Telerik RadTreeView):

 

    <telerik:RadTreeView Width="225" BorderBrush="Transparent" HorizontalAlignment="Left" Background="Transparent" FontWeight="SemiBold">
    <telerik:RadTreeViewItem Header="Customer"/>
    <telerik:RadTreeViewItem Header="Sites" ItemsSource="{Binding Sites}">
        <telerik:RadTreeViewItem.ItemTemplate>
            <DataTemplate>
                <telerik:RadTreeViewItem Header="{Binding Key}">
                    <telerik:RadTreeViewItem Header="Material Profiles"/>
                    <telerik:RadTreeViewItem Header="Prices"/>
                </telerik:RadTreeViewItem>
            </DataTemplate>
        </telerik:RadTreeViewItem.ItemTemplate>
    </telerik:RadTreeViewItem>
</telerik:RadTreeView>

As you can see the XAML is exactly the same in both cases except of the make of the components.

Thanks

0
Tony
Top achievements
Rank 1
answered on 05 Dec 2011, 11:47 AM
Anyone?  Am I doing something wrong with the Telerik controls or is this a bug?

Thanks
0
Petar Mladenov
Telerik team
answered on 05 Dec 2011, 06:42 PM
Hello Tony,

 We understand your requirements and we agree that the .Net TreeView and our RadTreeView work in a different way. We logged a feature request in our PITS(TreeView: Ability to have both static and bound RadTreeViewItems in different hierarchy levels) and it will be soon available in this link. You can vote for it and this way you will increase its development priority.
However, we highly suggest you to use HierarchicalDataTemplates( SL demo link here) and you will be able to achieve your desired look and feel.

Greetings,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
TreeView
Asked by
Tony
Top achievements
Rank 1
Answers by
Tony
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or