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

Expand and Collapse Timeline groups

3 Answers 137 Views
TimeLine
This is a migrated thread and some comments may be shown as answers.
Alberto
Top achievements
Rank 1
Alberto asked on 24 Mar 2014, 06:25 PM
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

3 Answers, 1 is accepted

Sort by
0
Boris
Telerik team
answered on 27 Mar 2014, 11:48 AM
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.

 
0
Alberto
Top achievements
Rank 1
answered on 27 Mar 2014, 04:38 PM
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 
0
Boris
Telerik team
answered on 01 Apr 2014, 04:18 PM
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.

 
Tags
TimeLine
Asked by
Alberto
Top achievements
Rank 1
Answers by
Boris
Telerik team
Alberto
Top achievements
Rank 1
Share this question
or