2014-05-12 48 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

回答

相關問題