using System.Windows; using System.Windows.Controls; using Microsoft.Xaml.Behaviors; using Syncfusion.Windows.Controls.Gantt; using Syncfusion.Windows.Controls.Gantt.Chart; using Syncfusion.Windows.Controls.Grid; using DependencyObjectExtensions = Syncfusion.Windows.Controls.Gantt.DependencyObjectExtensions; namespace PRSDesktop { public class GanttSetupBehaviour : Behavior { /// /// Called when [attached]. /// protected override void OnAttached() { AssociatedObject.Loaded += AssociatedObject_Loaded; } /// /// Handles the Loaded event of the AssociatedObject control. /// /// The source of the event. /// The instance containing the event data. private void AssociatedObject_Loaded(object sender, RoutedEventArgs e) { if (AssociatedObject.GanttGrid != null) AssociatedObject.GanttGrid.UpdateMode = UpdateMode.PropertyChanged; var chart = DependencyObjectExtensions.FindName(AssociatedObject, "PART_GanttChart"); if (chart != null) { var chartScrollViewer = DependencyObjectExtensions.FindName(chart, "PART_GanttChartScrollViewer"); if (chartScrollViewer != null) { // To make the GanttChart's Vertical Scroll bar visible. chartScrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Visible; chartScrollViewer.ScrollChanged += ChartScrollViewer_ScrollChanged; } } } private void ChartScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e) { // To sync the GanttGrid's vertical scroll with GanttChart's Vertical scroll offset. AssociatedObject.GanttGrid.InternalGrid.SetVerticalOffset(e.VerticalOffset); } /// /// Called when [detaching]. /// protected override void OnDetaching() { AssociatedObject.Loaded -= AssociatedObject_Loaded; } } }