Expand and Collapse Timeline groups

4 posts, 0 answers
  1. Alberto
    Alberto avatar
    26 posts
    Member since:
    Nov 2012

    Posted 24 Mar 2014 Link to this post

    Hello,

    I was reading this help: http://www.telerik.com/help/wpf/radtimeline-howto-expand-collapse-groups.html, I am looking a way to expand and collapse groups programatically.
    In my demo project I have several groups and I would like that when I expand a group the other groups must be collapsed, is there an event when a group is expanded so I can collapse the other groups?

    If possible could you provide a sample project?

    Thanks in advance,

    Alberto
  2. Boris
    Admin
    Boris avatar
    276 posts

    Posted 27 Mar 2014 Link to this post

    Hello Alberto,

    The RadTimeline has a build-in GroupExpandMode property . You can set it to Single in order to have only one expanded group at a time.
    You can read more about the GroupExpandMode in our Grouping documentation article.

    I attached a SDK sample application that demonstrates the mentioned property. 

    On a side note you can find all the xaml - SDK sample applications in our GitHub repository.

    I hope this helps.

    Regards,
    Boris Penev
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Alberto
    Alberto avatar
    26 posts
    Member since:
    Nov 2012

    Posted 27 Mar 2014 in reply to Boris Link to this post

    Hello Boris,

    I missed to explain a bit more my project, I have several groups and lets say they are divided into two sections (red and blue in the first attached image), I would like to open one or more groups from a section, but if there is an open group in the other section this group must be closed.

    I could only have open groups from one section, like the secod image.

    That's why I wanted to know if there is an event when a group is expanded so I can collapse the other groups.

    Thanks,

    Alberto 
  5. Boris
    Admin
    Boris avatar
    276 posts

    Posted 01 Apr 2014 Link to this post

    Hello Alberto,

    I updated the example to demonstrate how you can attach an TimelineItemGroupControl.Expanded event to each group. This is done in the Loaded event handler of the RadTimeline. There you can get all the groups by using the ChildrenOfType<TimelineItemGroupControl>() extension method of the Telerik.Windows.Controls

    private void xTimeline3_Loaded(object sender, RoutedEventArgs e)
            {
                var groups = this.xTimeline3.ChildrenOfType<TimelineItemGroupControl>();
                groups.ToList().ForEach(g => g.Expanded += this.GroupExpanded);
            }

    In the GroupExpanded method you can expand / collapse every group. In the code-snippet we set the IsExpanded property to False on every group different that the sender.

    private void GroupExpanded(object sender, Telerik.Windows.RadRoutedEventArgs e)
            {
                var groups = this.xTimeline3.ChildrenOfType<TimelineItemGroupControl>();
     
                groups.ToList().ForEach(x =>
                    {
                        if (x != sender)
                        {
                            x.IsExpanded = false;
                        }
                    });
            }

    We believe you will be able to extend this code to better match your requirements for section of groups.

    I hope this helps.

    Regards,
    Boris Penev
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
Back to Top