2014-05-12 50 views
0

我需要将MouseBinding添加到ListBoxItemsInputBindings。我知道如何在xaml中做到这一点。如何以编程方式绑定到模板中的输入绑定

<ControlTemplate TargetType="{x:Type ListBoxItem}"> 
    <Grid> 
     <Border x:Name="MyBorder" ...> 
      <Border.InputBindings> 
       <MouseBinding MouseAction="LeftClick" 
          Command="{Binding SomeCommand}"/> 
      </Border.InputBindings> 
     </Border> 
    </Grid> 
    ... 
</ControlTemplate> 

但我需要知道如何在代码隐藏中编写上述代码。无论如何要这样做?

+0

你想获得一个EventArgs而点击这个ListBoxItem? –

+0

我需要将命令绑定到ListBoxItem的鼠标单击事件。 – user3530012

回答

相关问题