Partially Bound RadTreeView

4 posts, 0 answers
  1. Tony
    Tony avatar
    3 posts
    Member since:
    Jul 2011

    Posted 30 Nov 2011 Link to this post

    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>
  2. Tony
    Tony avatar
    3 posts
    Member since:
    Jul 2011

    Posted 30 Nov 2011 Link to this post

    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

  3. UI for WPF is Visual Studio 2017 Ready
  4. Tony
    Tony avatar
    3 posts
    Member since:
    Jul 2011

    Posted 05 Dec 2011 Link to this post

    Anyone?  Am I doing something wrong with the Telerik controls or is this a bug?

    Thanks
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 05 Dec 2011 Link to this post

    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 >>

Back to Top