0

I want to bind the MouseDoubleClick (or PreviewMouseDoubleClick) to my custom Command defined in my custom WPF Control.

The problem is that it does not work.

...
<Popup>
...
<!--This CommandBinding **DOES NOT WORK** !-->
<ListBox Grid.Row="1"
   x:Name="PART_lBox"                                                                      
   VirtualizingStackPanel.IsVirtualizing="True"
   DisplayMemberPath="{TemplateBinding DisplayMemberPath}"                                                                     
   ItemsSource="{TemplateBinding ItemsSource}">
 <ListBox.InputBindings>                                                                    
  <MouseBinding Command="{x:Static local:ListPicker.AcceptCommand}"                                                                                  
       MouseAction="LeftDoubleClick" />
 </ListBox.InputBindings>
</ListBox>

<!--This CommandBinding **WORKS** !-->
<Button Grid.Row="0"
  Grid.Column="1"                                                                        
  HorizontalAlignment="Right"
  Command="{x:Static local:ListPicker.AcceptCommand}"
  Content="Accept" />
...
</Popup>
theSpyCry
  • 12,073
  • 28
  • 96
  • 152
  • There is no direct way. But, you can achieve this by creating a custom click handler. What I did was, I had a click counter class, which will start a timer whenever the click method is invoked. It will increase the click count as and when a click is received within the given time. For me I had 2000 milliseconds as interval between each click. If you want to know how many correct clicks were made. You need to use the ClickCount property of that class. I had to use it for situation to perform different actions for single click, double click and triple click. HTH – Prince Ashitaka Aug 21 '10 at 14:14

1 Answers1

0

There is no direct way of doing it. Check this post http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/da54880a-b11c-4d3b-995b-546055398997

Steven
  • 681
  • 10
  • 6