I need to add a MouseBinding
to the InputBindings
of the ListBoxItems
. I know how to this in xaml.
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid>
<Border x:Name="MyBorder" ...>
<Border.InputBindings>
<MouseBinding MouseAction="LeftClick"
Command="{Binding SomeCommand}"/>
</Border.InputBindings>
</Border>
</Grid>
...
</ControlTemplate>
But I need to know how to write the above code in code-behind. Is there anyway to do that?