RadTreeView Sorting for Windows WPF

6 posts, 1 answers
  1. Barry
    Barry avatar
    29 posts
    Member since:
    May 2016

    Posted 30 May Link to this post

    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

  2. Answer
    Martin
    Admin
    Martin avatar
    1101 posts

    Posted 31 May Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Barry
    Barry avatar
    29 posts
    Member since:
    May 2016

    Posted 31 May in reply to Martin Link to this post

    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.

  5. Barry
    Barry avatar
    29 posts
    Member since:
    May 2016

    Posted 31 May in reply to Barry Link to this post

    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...
  6. Barry
    Barry avatar
    29 posts
    Member since:
    May 2016

    Posted 02 Jun in reply to Martin Link to this post

    Is there a way to implement sort arrows, the same as in RadGridView ?
  7. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 06 Jun Link to this post

    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.
Back to Top
UI for WPF is Visual Studio 2017 Ready