WPF Combobox not navigating to items on key press
-
Hi.. Inside my code the combobox is not responding to key press events.. like if user presses M, combobox should select Marrylands in the dropdownlist like the ASP .net combobox does. Can anyone please help??? <ComboBox HorizontalAlignment="Right" Height="23" Name="cmbPortsFrom" KeyDown="cmbPortsFrom_KeyDown" Width="105" SelectedIndex="0" Grid.Row="2" Grid.Column="0" > <ComboBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel /> </ItemsPanelTemplate> </ComboBox.ItemsPanel> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Code}" FontSize="15" Height="20"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> codebehind: Dim lDataSource2 As ICollection(Of BusinessLayer.Ports) lDataSource2 = mBalObjPorts.getPortData() Me.cmbPortsFrom.ItemsSource = lDataSource2
-
Hi.. Inside my code the combobox is not responding to key press events.. like if user presses M, combobox should select Marrylands in the dropdownlist like the ASP .net combobox does. Can anyone please help??? <ComboBox HorizontalAlignment="Right" Height="23" Name="cmbPortsFrom" KeyDown="cmbPortsFrom_KeyDown" Width="105" SelectedIndex="0" Grid.Row="2" Grid.Column="0" > <ComboBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel /> </ItemsPanelTemplate> </ComboBox.ItemsPanel> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Code}" FontSize="15" Height="20"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> codebehind: Dim lDataSource2 As ICollection(Of BusinessLayer.Ports) lDataSource2 = mBalObjPorts.getPortData() Me.cmbPortsFrom.ItemsSource = lDataSource2
-
apparently nothing, its an empty function.I believe the combobox should automatically select Marrylands from the list if user presses "M" key??
Perhaps your empty event is preventing this from occuring ?
Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
-
Perhaps your empty event is preventing this from occuring ?
Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
-
apparently nothing, its an empty function.I believe the combobox should automatically select Marrylands from the list if user presses "M" key??
If you are going to use a just a TextBox then do it this way,
<ComboBox x:Name="myComboBox" IsEditable="true" DisplayMemberPath="Code" Height="266" >
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>If no, you would have to implement the functionality on KeyDown event (specifically by overriding OnPreviewKeyDown). This[^] might be of help.
-
I have removed the function, still its not working. It could be because the combobox contains nearlly 500 rows? Anyhow i am writing the keypress event function to achieve this. Thanks.
-
If you are going to use a just a TextBox then do it this way,
<ComboBox x:Name="myComboBox" IsEditable="true" DisplayMemberPath="Code" Height="266" >
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>If no, you would have to implement the functionality on KeyDown event (specifically by overriding OnPreviewKeyDown). This[^] might be of help.