Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > TreeView > Selective Visibility of nodes

Answered Selective Visibility of nodes

Feed from this thread
  • christina noel avatar

    Posted on Jan 27, 2012 (permalink)

    Hi!

    I'm binding a virtualized RadTreeView to a (hierarchichal) ObservableCollection of a custom object.

    One of the fields on the custom object is "Active" (boolean).

    There is a toggle button on my user control that is supposed to control whether all of the objects show in the treeview or if only "Active" objects show.

    I'm having several problems:
    1) For an initial test, I tried just assuming that the toggle button is set to "Active only", and tried using container bindings to hide the items, but this seemed to have no effect. (The code I'm currently using is shown below).
    2) I have no idea how to turn the container bindings on and off based on the toggle button.
    3) The same observable collection is bound to a BreadcrumbBar, which needs to behave similarly to the treeview.

    I'm willing to take another approach entirely, if that will be better. I'm even willing to change the item's source entirely if you can recommend a way to filter without having to traverse the whole tree.

    --Christina

        <telerik:ContainerBindingCollection x:Key="FolderBindings">
            <telerik:ContainerBinding PropertyName="Visible" Binding="{Binding Active, Converter={StaticResource BooleanToVisibilityConverter}}"/>
     
        </telerik:ContainerBindingCollection>
    <telerik:RadTreeView x:Name="tvFolders"  Grid.Row="1" LoadOnDemand="tvFolders_LoadOnDemand"  IsLoadOnDemandEnabled="true"
                         telerik:StyleManager.Theme="{StaticResource MPTheme}"
                         Background="White" ItemsSource="{Binding Source={StaticResource FolderSource}, Path=FolderNodes}"
                         SelectionChanged="tvFolders_SelectionChanged" BringIntoViewMode="HeaderAndItems" IsVirtualizing="true"
                         telerik:TextSearch.TextPath="FileElementOID"
                         telerik:RadDragAndDropManager.AllowDrop="True" >
        <telerik:RadContextMenu.ContextMenu>
            <telerik:RadContextMenu Opened="FolderContextMenu_Opened" ItemClick="FolderContextMenu_ItemClick" ItemsSource="{StaticResource TVFolderContextMenuItems}" />
        </telerik:RadContextMenu.ContextMenu>
        <telerik:RadTreeView.ItemTemplate >
            <telerik:HierarchicalDataTemplate  ItemsSource="{Binding ChildFolders}" telerik:ContainerBinding.ContainerBindings="{StaticResource FolderBindings}" >
                <TextBlock Text="{Binding Name}">
                        <ToolTipService.ToolTip>
                            <TextBlock Text="{Binding Name}" />
                        </ToolTipService.ToolTip>
                    </TextBlock>
            </telerik:HierarchicalDataTemplate>
        </telerik:RadTreeView.ItemTemplate>
    </telerik:RadTreeView>

    Reply

  • Answer Petar Mladenov Petar Mladenov admin's avatar

    Posted on Feb 1, 2012 (permalink)

    Hello Christina Noel ,

    You can see why your ContainerBindingsCollection does not work by checking the output for BindingExpression Errors.
    I believe it is the wrong named property - you have typed Visible but the property of the RadTreeViewItem is Visibility. However there is a bug our RadTreeView that will stop you from using this approach:
    TreeView: The TreeViewPanel keeps the space for the collapsed items
    What we could suggest you is to filter your viewmodels when needed and assign new ItemsSource to the RadTreeView - this way you will workaround the mentioned bug. Is this suitable for you?

    Greetings,
    Petar Mladenov
    the Telerik team

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

    Reply

  • christina noel avatar

    Posted on Feb 1, 2012 (permalink)

    We've decided (for the time being) to just not include inactive objects in the ItemsSource for the treeview and breadcrumb bar. I've added to the votes for the bug you linked, and have started tracking it so that we can revisit this problem when the bug is resolved.

    Thank you!
    --Christina

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > TreeView > Selective Visibility of nodes
Related resources for "Selective Visibility of nodes"

Silverlight TreeView Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]