Hi,
I want to perform two different tasks on mouse left button’s single click & on double click event on a node. I implemented it, but there is one issue, that double click event is never catched.
Please have a look of the following code for your reference & then please let me know the solution:
.xaml code:
<
DataTemplate x:Key=“IconicNode”>
<StackPanel go:Node.SelectionElementName=“IconicNode”
go:Part.Selectable="True"
go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}"
go:Part.Movable="False" MouseLeftButtonDown="OnMouseLeftButtonDown">
<TextBlock Text="{Binding Path=Data.Key}">
<TextBlock.RenderTransform>
<RotateTransform Angle="-45" />
</TextBlock.RenderTransform>
</TextBlock>
<Image Source="{Binding Path=Data.NodeImage}" Stretch="Uniform"/>
<ToolTipService.ToolTip>
<TextBlock Text="{Binding Path=Data.ToolTipText}" ToolTipService.Placement="Top"
Visibility="{Binding Path=Data.ToolTipText.Length,
Converter={StaticResource theCountVisibilityConverter}}" />
</ToolTipService.ToolTip>
</StackPanel>
</DataTemplate>
.cs code:
private
void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (DiagramPanel.IsDoubleClick(e))
{
Node node = Part.FindAncestor<Node>(sender as UIElement);
if (node != null && node.Data != null)
{
e.Handled =
true;
MessageBox.Show("Double clicked on " + node.Data.ToString());
}
}
else
{
Node node = Part.FindAncestor<Node>(sender as UIElement);
if (node != null && node.Data != null)
{
e.Handled =
true;
MessageBox.Show("Single clicked on " + node.Data.ToString());
}
}
}