简体   繁体   English

组合框TouchDown和MouseDown不会触发

[英]Combobox TouchDown and MouseDown does not fire

I am using WPF and has a combobox which is editable. 我正在使用WPF,并且有一个可编辑的组合框。

I added TouchDown and MouseDown event handler, but it never fire up when I touch on the combobox. 我添加了TouchDown和MouseDown事件处理程序,但是当我触摸组合框时它永远不会启动。

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? 发现了这一点: 如何在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" : 您需要添加属性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" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM