Synchronize Scroll of GantView with other ScrollViewer

6 posts, 1 answers
  1. Julien
    Julien avatar
    20 posts
    Member since:
    Oct 2013

    Posted 21 Nov 2014 Link to this post

    Hello everybody,

    I try to synchronize the scroll into the gantView (the scroll into the panel which show event) with an other scrollViewer outside the ganttView.
    the WrapPanel into scroll Viewer have the same size that event panel in the gantt, ant this panel contains month with same size thant month in the gantView (same number of month in my panel and month in the visible range in the gantt view, month represent by a rectangle and other thing ). The goal is to move scroll in one according to the other, to have the same months showing in the gantView and my panel.
    fo this, I thinking suscribe to the event ScrollChanged in the two controls and work with HorizontalOffset in order to synchronize the two scroll, but I don't find this event in the ganttView.

    Do you think what I try it's possible ?

    Thanks,

    Julien
  2. Answer
    Polya
    Admin
    Polya avatar
    199 posts

    Posted 25 Nov 2014 Link to this post

    Hello Julien,

    Internally the RadGanttView contains 3 ScrollBars - 2 horizontal ( for the GridView part and for the TimeRuler part ) and 1 vertical.
    We can get these ScrollBars using the RadGanttView.ChildrenOfType<ScrollBar>() method. We can then use the Value if the TimeRuler area horizontal ScrollBar to scroll some other ScrollViewer with a horizontal offset equal to this Value.
    I've attached a sample project demonstrating this approach. I handle the RadGanttView.SelectionChanged event and in it I scroll a ScrollViewer containing a ListBox with the same offset as the TimeRuler horizontal ScrollBar.

    Hopefully this helps.

    Regards,
    Polya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Julien
    Julien avatar
    20 posts
    Member since:
    Oct 2013

    Posted 12 Dec 2014 in reply to Polya Link to this post

    OK thanks you it's works perfectly

    Thanks

    Julien
  5. Andrea
    Andrea avatar
    2 posts
    Member since:
    Aug 2016

    Posted 04 Nov Link to this post

    How can I detect the TimeRuler horizontal ScrollBar scroll event? RadGanttView.SelectionChanged event works fine if I select a Task on the Gantt but if I scroll the bar nothing happens.

    Regards

    Andrea

  6. Polya
    Admin
    Polya avatar
    199 posts

    Posted 07 Nov Link to this post

    Hello Andrea,

    As mentioned in the previous post - "internally the RadGanttView contains 3 ScrollBars - 2 horizontal ( for the GridView part and for the TimeRuler part ) and 1 vertical." The second ScrollBar is the TimeLine area horizontal scroll bar.
    One approach is to get this scroll bar when the RadGanttView loads and then add handler to its Scroll event:
    private void MainWindow_Loaded(object sender, RoutedEventArgs e)
    {
        var scrBars = this.ganttview.ChildrenOfType<ScrollBar>().ToArray();
        if (scrBars.Length == 3)
        {
            var timeLineAreaHorizontalScrollbar = scrBars[1];
            timeLineAreaHorizontalScrollbar.Scroll += timeLineAreaHorizontalScrollbar_Scroll;
        }
    }
     
    private void timeLineAreaHorizontalScrollbar_Scroll(object sender, ScrollEventArgs e)
    {
        // custom logic.
    }

    Hope this helps.

    Regards,
    Polya
    Telerik by Progress
    Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
  7. Andrea
    Andrea avatar
    2 posts
    Member since:
    Aug 2016

    Posted 07 Nov in reply to Polya Link to this post

    Thanks! Your suggestion helped me accomplish what i wanted!

    Best regards

    Andrea

Back to Top
UI for WPF is Visual Studio 2017 Ready