Hello,
I'm using GanttControl and I wold like to know how I can distinguish the right click from a left click on a taks.
Having seen this question
(https://www.syncfusion.com/forums/164085/click-event-on-gantt-chart )
, I know when I have clicked on a task. But I don't know how to
distinguish
what type of click I have made.
Kind regards,
Jon
|
<Window.Resources>
<Style TargetType="chart:GanttNode"
x:Key="TaskNode">
<Setter Property="HorizontalAlignment"
Value="Left" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="chart:GanttNode">
<Canvas Height="11">
……
<Border Name="PART_Border">
<i:Interaction.Behaviors>
<local:GanttNodeCustomizationBehavior />
</i:Interaction.Behaviors>
</Border>
…….
</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
</Window.Resources>
<Grid>
<gantt:GanttControl ItemsSource="{Binding TaskCollection}">
<gantt:GanttControl.Resources>
<Style TargetType="chart:GanttNode"
BasedOn="{StaticResource TaskNode}" />
</gantt:GanttControl.Resources>
</gantt:GanttControl>
</Grid> |
|
class GanttNodeCustomizationBehavior : Behavior<Border>
{
protected override void OnAttached()
{
this.AssociatedObject.Loaded += new RoutedEventHandler(AssociatedObject_Loaded);
}
void AssociatedObject_Loaded(object sender, RoutedEventArgs e)
{
this.AssociatedObject.PreviewMouseLeftButtonDown += AssociatedObject_PreviewMouseLeftButtonDown; ;
this.AssociatedObject.MouseRightButtonDown += AssociatedObject_MouseRightButtonDown;
}
private void AssociatedObject_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
// Add your codes here.
}
private void AssociatedObject_MouseRightButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
// Add your codes here.
}
protected override void OnDetaching()
{
this.AssociatedObject.Loaded -= new RoutedEventHandler(AssociatedObject_Loaded);
}
} |