TreeListView doesn't have a vertical scrollbar unless it's Height is fixed

1 Answer 48 Views
TreeListView
D
Top achievements
Rank 1
D asked on 24 Jul 2024, 07:04 AM

I have the following XAML code:

<telerik:RadLayoutControl >
    <telerik:RadTabControl>
        <telerik:RadTabItem Header="Admin">
            <telerik:RadTabItem.Content>
                <telerik:RadLayoutControl>
				
                    <!-- Left Side -->
                    <telerik:RadTreeListView Name="TreeListView" ItemsSource="{Binding Arguments}">
                        <telerik:RadTreeListView.ChildTableDefinitions>
                            <telerik:TreeListViewTableDefinition ItemsSource="{Binding Children}" />
                        </telerik:RadTreeListView.ChildTableDefinitions>
                    </telerik:RadTreeListView>
					
                    <telerik:LayoutControlSplitter />

                    <!-- Right Side -->
                    <telerik:RadTabControl Width="Auto">
                        <telerik:RadTabItem Header="Tab 1">
                            <telerik:RadGridView></telerik:RadGridView>
                        </telerik:RadTabItem>
                        <telerik:RadTabItem Header="Tab 2">
                            <telerik:RadGridView></telerik:RadGridView>
                        </telerik:RadTabItem>
                    </telerik:RadTabControl>

                </telerik:RadLayoutControl>
            </telerik:RadTabItem.Content>
        </telerik:RadTabItem>
    </telerik:RadTabControl>
</telerik:RadLayoutControl>

The problem is that when I populate the TreeListView with big number of items, it stretches the topmost RadLayoutControl parent (look at the scrollbar position on the far right). The behavior I expect is that the TreeListView itself gets a vertical scrollbar like when I set it to a fixed Height. But I want it to be resizable with the window.

How can I achieve such behavior?

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 24 Jul 2024, 08:33 AM

Hello,

This happens because the layout panelsused in the RadLayoutControl behave very similar to StackPanel. Basically, they measure their children with inifinity, or in other words give them as much space as they need.

To get the desired behavior you should limit the size of the RadTreeListView control. One way to do that is to set a fixed Height for the control. Or alternatively, you can wrap it in a LayoutControlGroup and bind the Height to the ActualHeight of the group.

    <telerik:LayoutControlGroup>
        <telerik:RadTreeListView Name="TreeListView" ItemsSource="{Binding Arguments}" Height="{Binding RelativeSource={RelativeSource AncestorType=telerik:LayoutControlGroup}, Path=ActualHeight}">
                <!-- other xaml here -->
        </telerik:RadTreeListView>
    </telerik:LayoutControlGroup>

I hope this helps.

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

D
Top achievements
Rank 1
commented on 24 Jul 2024, 10:33 AM

Thank you. It helps, but if I move the LayoutControlSplitter to the most left the TreeListView`s scrollbar disappears and the app freezes. 
Martin Ivanov
Telerik team
commented on 26 Jul 2024, 11:51 AM

Indeed, in some cases the LayoutGroupControl may try to size according to the size of its content, which will break the ActualHeight binding by creating a cyclic dependency, thus freezing the application. The most reliable solution that I can suggest is to use a fixed size of the RadTreeListView by setting Height or MaxHeight.
D
Top achievements
Rank 1
commented on 01 Aug 2024, 06:12 AM

Oh, that's really sad... thank you
Tags
TreeListView
Asked by
D
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or