Could you please help me with a solution for this? I have tried using CollectionViewSource, but not able to filter below the Root level I am able to filter only at the top level.
Lets for example I have this Tree - got this from one of your examples.
Animal
Dog
Cat
Fish
Fresh Water
Roach
Bream
Salt Water
Skate
SkateChild
Soul
In this example, If I type "d" , I should get the following result.
Animal
Dog
Fish
Salt Water
Skate
SkateChild
Please let me know if you can help me with a solution that would work for n level of nodes.
This is highly critical for us and any help on this is really appreciated.
13 Answers, 1 is accepted
My ItemTemplate in the XAML looks like this.
<telerik:RadTreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Path=Folders}" >
<StackPanel Orientation="Horizontal" Margin="0" Tag="{Binding}" HorizontalAlignment="Stretch"
Background="Transparent">
<Image Source="D:\iApps\iEconomics\Dev\EOG.Economics.UIElements\Images\folder.png" Margin="0,1,0,0" Height="16" Width="16" />
<TextBlock Text="{Binding Text}" Margin="5,1,0,0" />
</StackPanel>
<HierarchicalDataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=IsVisible}" Value="False">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate>
</telerik:RadTreeView.ItemTemplate>
The behaviour I am seeing with this is that, after Filtering it is showing the Nodes that did not match the criteria as Blank Nodes ie no name next to the Node.
I am attaching the screen shot of what I am explaining.
Could you please help me out on this?
The behavior you have come up with is expected. The defined HierarChicalDataTemplate defines the way the Header of the RadTreeViewItems will look like. When the Trigger is triggerred, the Header becomes Collapsed, but the CheckBox, Expander Toggle Button and other elements are not part of the Header and that is why they are not Collapsed. Unfortunately, collapsing the whole RadTreeViewItem is not possible which is previously logged in our PITS.
We'll need some time in order to prepare a good filtering example in for the RadTreeView. We'll do our best to create one tomorrow and post it here. Thank you in advance for your patience.
Petar Mladenov
the Telerik team
Attached you can find the promised example.
Regards,Petar Mladenov
the Telerik team
I believe there was a mistake in the project I sent you. I modified it now to create a new Hierarchy when filtering. Tomorrow I will try to optimize it since the performance is not good enough.
Kind regards,Petar Mladenov
the Telerik team
Yes, that's what I do. The performance is not quite good, but as I mentioned before , we cannot hide particular items - this is a bug in our RadTreeView logged here.
Regards,Petar Mladenov
the Telerik team
Hi, I want to implement a filter mechanism, just like VS2013 has.
However, as expected, the performance is poor. This is because when filtering, or when clearing the filters, the whole collection is being replaced, which makes the tree create all of the tree view items all over again.
If using UIVirtualization (which is not enabled by default), the results are much better, however, UIVirtualization sucks in that manner. The scroll is not smooth (because new tree view items are being created while scrolling). Furthermore, the scroll size is not accurate, and it keeps increasing while scrolling, so this is out of the question!
We have the 2012 controls, and I was expecting that this kind of problem will be fixed, and a feature like that would be out of the box (but it isn't).
I want to implement it using Visibility, however, it appears that you didn't think it through!
Although now the space is not reserved for the item is you change the ItemVisibility to collapsed, but this is why happens when you hide items.
If last child is being hidden, then the previous child still has the vertical line continuing like it still exists.
If all children are being hidden. then its parent still have the expander active... Look at the attached images.
We highly encourage you to try newer release of UI for WPF -at least Q1 or Q2 2015. In 2014 we introduced some fixes in RadTreeView which increased the performance of the scrolling in RadTreeView.
For the vertical lines, they are constructed by separate vertical lige segments which are part of every RadTreeViewItem's Control Template. There is no code responsible to cut the separate segment if the child items are hidden / collapsed. You can submit a feature request in our feedback portal and we will later review it and approve it.
Similar is true for the Expander Icon, there is no code to listen for children visibility change to control the expander. However, you can add application . viewmodel logic to implement such kind of functionality.
Regards,
Petar Mladenov
Telerik
I was assuming that the ItemVisibility would control both.
The vertical line is being drawn by looking at the Position (Top middle or bottom), which is a getter property of the treeviewitem.
I expected the position to take into account hidden items.
The internal property Position is not designed to take into account child items' visibility. However this is valid for feature request. You can submit it in our feedback portal.
Regards,
Petar Mladenov
Telerik