Question

Edit: It now looks like this is a bug with the Telerik controls I'm using. After re-implementing my XAML using the .Net TreeView I get the results I would expect. I've reported this to Telerik and will answer this posting after hearing back from them.

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>
Was it helpful?

Solution

Telerik have confirmed that this isn't possible with their RadTreeView control and they've added it to their TODO list.

Thanks for the comments anyway.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top