This question is locked. New answers and comments are not allowed.
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
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
>