Hi,
I'm using *Telerik UI for WPF with C#*
I need to be able to sort the top node list of my RadTreeView alphabetically - that's it !
So the user clicks on the header row "Project" and it sorts ASC, click again and it toggles to DESC.
All the examples I've come across are for other Telerik platforms (web or winforms etc.).
My TreeView:
<telerik:RadTreeView x:Name="ProjectsTreeView" Grid.Row="1"
telerik:PersistenceManager.StorageId="THOR_ProjectTree"
ItemsSource="{Binding ProjectData}"
ItemTemplate="{StaticResource Project}"
BorderBrush="Gray"
ItemsIndent="0"
SelectionMode="Single"
SelectedItem="{Binding SelectedTreeViewItem, Mode=TwoWay}"
ItemContainerStyle="{StaticResource ItemContainerStyle}"
ItemClick="ProjetsTreeView_ItemClick"
BorderThickness="1"/>
Please advise (C#),
Barry
5 Answers, 1 is accepted
RadTreeView for WPF doesn't support sorting. However, you can implement such behavior using custom code. Basically, you can manually sort the collection bound to the ItemsSource property of the treeview (or treeviewitem). You can find such approach explained in the Implement Search, Filter and Sort help article.
You can also consider using the RadTreeListView control which have a built-in sorting functionality.
Regards,
Martin
Telerik
thanks for getting back to me Martin.
I saw the example you posted (link) and it seems to use a RadComboBox within the RadTreeView. The one I was tasked to sort doesn't have that, although I suppose I could add one. The pasted definition in my original posting has the extent of it. It may be easiest to just implement the RadTreeListView instead, and let Telerik handle the rest.
If you are using the RadTreeListView control, a sort direction arrow will be displayed by default. But, if you are using the custom sorting implementation you will need to implement custom logic for displaying an arrow. For example, you can define an element (ex: ToggleButton) that defines the sort direction and when it is clicked you can change its appearance to match the newly applied order.
Regards,
Martin
Telerik