我正在开发一个wpf应用程序。我正在ComboBoxItem上写一个KeyDown事件,但无论如何这个事件都没有触发。我已经尝试了很多方法但是找不到解决方案。
我的代码如下:
<ComboBox Text="{Binding CurrentCountries}" ToolTip="{Binding CurrentCountries}" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Stretch"
Name="cmbCountry" IsEditable="True" IsReadOnly="True" TextSearch.TextPath="CountryName" HorizontalContentAlignment="Stretch"
Margin="80,14,0,0" VerticalAlignment="Top" Width="100 " ItemsSource="{Binding Country, Mode=TwoWay}"
SelectedItem="{Binding SelectedCountry,Mode= TwoWay}" Height="22" >
<ComboBox.ItemContainerStyle>
<Style TargetType="ComboBoxItem">
<EventSetter Event="KeyDown" Handler="Country_KeyDown_1"></EventSetter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBoxItem">
<CheckBox Name="Country" HorizontalAlignment="Stretch" Grid.Column="0" Content="{Binding CountryName}" IsChecked="{Binding IsChecked}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Checked">
<Commands:EventToCommand Command="{Binding DataContext.CountryCheckedCmd,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:RadWindow}}}" CommandParameter="{Binding ElementName=Country}" ></Commands:EventToCommand>
</i:EventTrigger>
<i:EventTrigger EventName="Unchecked">
<Commands:EventToCommand Command="{Binding DataContext.CountryUnCheckedCmd,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:RadWindow}}}" CommandParameter="{Binding ElementName=Country}" ></Commands:EventToCommand>
</i:EventTrigger>
</i:Interaction.Triggers>
</CheckBox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ComboBox.ItemContainerStyle>
</ComboBox>