October 23, 2020, 08:49:09 AM

See more Support incidents in our old archived forum.

Author Topic: Sync a GanttControl and a FlexyGantt Selection  (Read 2907 times)


  • Customers
  • Newbie
  • *
  • Posts: 21
Sync a GanttControl and a FlexyGantt Selection
« on: July 28, 2014, 12:47:01 PM »

I've got two controls on my form, a GanttControl, and a FlexyGantt.
The GanttControl has an entity collection as a DataSource, and the FlexyGantt has a datasource based on the GanttControl model, using ResourceToActivitiesListConverter class.
The display (width, timeline) are synchronized using a SyncGantt class, found in your sample.

I'd like that when I click on a task in the FlexyGantt, the corresponding task in the GanttControl should be bring into view. That maybe means that some nodes should be expanded in the GanttControl.

I already can detect the click on a task in the FlexyGantt, and retrieve ths entity object binded to it, but I can't figure how to show the same task in the GanttControl.

Could you help me, please ?


  • RQ Members
  • Full Member
  • *
  • Posts: 149
Re: Sync a GanttControl and a FlexyGantt Selection
« Reply #1 on: July 28, 2014, 04:39:50 PM »

You can listen for the "PreviewMouseDown" event of TaskItemTemplate in FlexyGantt, and update the ProjectGantt like this,

Code: [Select]
        <Grid MouseEnter="Task_MouseEnter" MouseLeave="Task_MouseLeave" ToolTipService.ToolTip="{Binding  ActivityName}"
            <Rectangle x:Name="taskBar" HorizontalAlignment="Stretch"
                Fill="{StaticResource TaskItemBarFill}" Stroke="Blue"
                    StrokeThickness="1" RadiusX="4" RadiusY="4"  />

            <!-- Include a thumb with name "dragThumb" to enable drag-moving the task functionality.-->
            <!-- ZIndex=2 ensures this is drawn above the Rectangle -->
            <Thumb x:Name="dragThumb" Canvas.ZIndex="2" />
            <!-- Include a thumb with name "resizeThumb" to enable resizing the task functionality -->
            <!-- ZIndex=3 ensures this is drawn above the dragThumb -->
            <Thumb x:Name="resizeThumb" Canvas.ZIndex="3" HorizontalAlignment="Right" Cursor="SizeWE"
            Width="3" />

In C#:
Code: [Select]
private void Grid_PreviewMouseDown(object sender, MouseButtonEventArgs e)
    Grid grid = sender as Grid;
    IActivity selectedAct = grid.DataContext as IActivity;

    IActivity parentAct = selectedAct.Parent;
    List<IActivity> parentActs = new List<IActivity>();

    while (parentAct != null)
        parentAct = parentAct.Parent;
    for (int i = parentActs.Count - 1; i >= 0; i--)
        IActivityView view = this.ganttControl.ActivityViews[parentActs[i]];
        view.IsExpanded = true;

    IActivityView selectedActView = this.ganttControl.ActivityViews[selectedAct];