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

RadTreeViewItem Visibility not Collapsing ItemsPanel space

6 Answers 241 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 25 Aug 2010, 06:46 PM
I have a treeview where I dynamically change the Visibility of the RadTreeViewItem that is added to the the tree.  Unfortuantely the ItemsPresenter of the Parent item seems to be taking up the full space even though some items are not visibility.  Attached is a screenshot of this.

<UserControl 
    x:Class="Telerik_Q2_2010_Samples.MainPage"
    xmlns:c="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
    <UserControl.Resources>
        <telerik:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </UserControl.Resources>
      
    <StackPanel x:Name="LayoutRoot" Margin="30">
  
        <c:RadTreeView>
            <c:RadTreeViewItem Header="TestA" IsExpanded="True">
                <c:RadTreeViewItem Header="Test1" />
                <c:RadTreeViewItem Header="Test2" Visibility="{Binding IsChecked, ElementName=toggle, Converter={StaticResource BooleanToVisibilityConverter}}" />
                <c:RadTreeViewItem Header="Test3" />
                <c:RadTreeViewItem Header="Test4" />
            </c:RadTreeViewItem>
            <c:RadTreeViewItem Header="TestB" />
        </c:RadTreeView>
        
        <ToggleButton x:Name="toggle" Content="Toggle" HorizontalAlignment="Left" />
    </StackPanel>
</UserControl>


I'm using the SL3 8/12/2010 build.

6 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 31 Aug 2010, 09:45 AM
Hi Ben,

Yes, you are right. The parent RadTreeViewItem forms a gap when Visibility property of its child is changed.

There are several ways to work around the issue and accomplish fluid UI when changing the Visibility property of the RadTreeViewItem:
1. Change the ItemsPanel property of the RadTreeViewItem via style. This will result in proper resizing of the parent tree view item. But this will disable the implemented virtualization in the default item panel (TreeViewPanel). Meaning that virtualization of the tree will not work. This approach is applicable if you won't need the virtualization and your tree view is relatively small.
2. Change the underling data collection itself instead manipulating the Visibility property of the RadTreeViewitem. In this scenario you will need to use data binding and remove/add elements in the data source. This approach is applicable when you have relatively big tree (also consider using virtualization and load on demand).

I'm attaching a sample project demonstrating both approaches. You can take a look at the MainPage files and play around with commented code fragments. I hope this info will help you solve the issue you are experiencing. If you require more info don't hesitate to contact us.

All the best,
Hristo Milyakov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ben
Top achievements
Rank 1
answered on 31 Aug 2010, 06:57 PM
I only have about 100 rows max.  Changing the ItemsPanel to a StackPanel worked for me.

Thanks.
0
Ville
Top achievements
Rank 1
answered on 08 Dec 2010, 11:40 PM
Has the solution #1 been implemented in the latest DLLs?
0
Hristo
Telerik team
answered on 09 Dec 2010, 04:59 PM
Hello Giuliano,

The first solution is custom code you should implement yourself. We can not change the TreeViewPanel with StackPanel because this will disable the virtualization features of the tree for all control users.

Let me know if you need more info on the topic.

Greetings,
Hristo
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Murray
Top achievements
Rank 2
answered on 29 Aug 2011, 07:14 PM
Is there a way to collapse the visibility of the parent node items? Your sample is for SubEntities.
0
Murray
Top achievements
Rank 2
answered on 29 Aug 2011, 07:39 PM
Never mind I figured it out.
Tags
TreeView
Asked by
Ben
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Ben
Top achievements
Rank 1
Ville
Top achievements
Rank 1
Murray
Top achievements
Rank 2
Share this question
or