ListBox MouseBinding to Command无法正常工作

时间:2010-01-28 08:23:51

标签: wpf listbox command commandbinding inputbinding

我想将MouseDoubleClick(或PreviewMouseDoubleClick)绑定到我的自定义WPF控件中定义的自定义命令。

问题在于它不起作用。

...
<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>

1 个答案:

答案 0 :(得分:0)