RadiantQ Forum
Product => WPF Gantt Package => Topic started by: d.laumaille on July 28, 2014, 12:47:01 PM
-
Hi,
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 ?
-
d.laumaille,
You can listen for the "PreviewMouseDown" event of TaskItemTemplate in FlexyGantt, and update the ProjectGantt like this,
In XAML:<fxgantt:FlexyGantt.TaskItemTemplate>
<DataTemplate>
<Grid MouseEnter="Task_MouseEnter" MouseLeave="Task_MouseLeave" ToolTipService.ToolTip="{Binding ActivityName}"
PreviewMouseDown="Grid_PreviewMouseDown">
<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" />
</Grid>
</DataTemplate>
</fxgantt:FlexyGantt.TaskItemTemplate>
In C#: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)
{
parentActs.Add(parentAct);
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];
this.ganttControl.GanttTable.ScrollIntoView(selectedActView);
}
Regards,
-Raja.