Key down event not firing for ComboBoxItem in WPF

I am working on a wpf application. I am writing a KeyDown event on the ComboBoxItem, but somehow this event is not firing. I've tried many ways but couldn't find a solution.

My code looks like this:

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

      

+3


source to share





All Articles