Issue with double click event on node

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());

}

}

}

I don’t understand what the problem is. If I declare a MouseLeftButtonDown event handler in a Node DataTemplate, it gets called reliably, and DiagramPanel.IsDoubleClick returns true if it’s a double-click.

Does double-clicking not work for you in the Logic Circuit, Org Chart Bus, or Org Chart Editor samples?

Hi,

It works, only if you have only condition to check for double click. But if you also want to perform something on single click, then condition to check for double click is never true.
Please try with my following small function:

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());

}

}

}

I modified the GoSilverlightMinimal app by adding:
MouseLeftButtonDown=“Border_MouseLeftButtonDown_1”
to the Node DataTemplate and implementing that event handler as:
private void Border_MouseLeftButtonDown_1(object sender, System.Windows.Input.MouseButtonEventArgs e) {
System.Diagnostics.Debug.WriteLine(Northwoods.GoXam.DiagramPanel.IsDoubleClick(e));
}

It printed “False” on each node click that was not a double-click.

ok,

Now I got the point. Issue was that I was displaying msg box in both cases. Due to which, msg for double click is never displayed.

Thanks for the hint.