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

RadTreeView Sorting for Windows WPF

5 Answers 404 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Barry
Top achievements
Rank 1
Barry asked on 30 May 2016, 09:31 PM

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

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 31 May 2016, 12:39 PM
Hello Barry,

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
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Barry
Top achievements
Rank 1
answered on 31 May 2016, 02:36 PM

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.

0
Barry
Top achievements
Rank 1
answered on 31 May 2016, 02:48 PM
Ignore the bit about the ComboBox...I should of looked at the example at the very top of the page you linked to...that just decides the sort order.....thanks...
0
Barry
Top achievements
Rank 1
answered on 02 Jun 2016, 09:03 PM
Is there a way to implement sort arrows, the same as in RadGridView ?
0
Martin Ivanov
Telerik team
answered on 06 Jun 2016, 12:08 PM
Hello Barry,

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
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
TreeView
Asked by
Barry
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Barry
Top achievements
Rank 1
Share this question
or