I am using WPF and has a combobox which is editable.
I added TouchDown and MouseDown event handler, but it never fire up when I touch on the combobox.
What I plan to do is to have the drop down listed down when I touch or click on the combobox.
How can I do it?
<ComboBox Name="cbProductList" Height="45" Width="260" IsEditable="True"
ItemsSource="{Binding Source={StaticResource ProductsSource}}"
DisplayMemberPath="Name" SelectedValuePath="ProductId"
SelectedIndex="0" FontSize="23" FontFamily="Segoe WP"
VerticalAlignment="Stretch" FlowDirection="LeftToRight"
HorizontalAlignment="Left" HorizontalContentAlignment="Left"
SelectionChanged="cbProductList_SelectionChanged" />
Found this: How do I show the drop-down in a combobox in WPF?
But this event fire when something is type. I want it to fire when the combobox is clicked.
You need to add the property AutoPostBack="true"
:
<ComboBox Name="cbProductList" Height="45" Width="260" IsEditable="True"
ItemsSource="{Binding Source={StaticResource ProductsSource}}"
DisplayMemberPath="Name" SelectedValuePath="ProductId"
SelectedIndex="0" FontSize="23" FontFamily="Segoe WP"
VerticalAlignment="Stretch" FlowDirection="LeftToRight"
HorizontalAlignment="Left" HorizontalContentAlignment="Left"
SelectionChanged="cbProductList_SelectionChanged"
autopostback="true" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.