tags:

views:

392

answers:

1

Hopefully someone can help because I haven't been able to figure this out. Here's my xaml code for the popup/combo box, please not there is other code before and after this for the rest of the layout.

    <Popup x:Name="popupMethods" Height="400" Width="150" 
       StaysOpen="False" Placement="Bottom" IsOpen="false"
       HorizontalAlignment="Left">
                <ComboBox x:Name="combo" MouseLeftButtonDown="combo_MouseDown">
                    <TextBlock>Hello</TextBlock>
                    <TextBlock>World</TextBlock>
                    <TextBlock>This</TextBlock>
                    <TextBlock>is</TextBlock>
                    <TextBlock>Autocomplete</TextBlock>
                    <TextBlock>Textbox</TextBlock>
                </ComboBox>
    </Popup>

Have it set up to popup on the screen whenever the user starts typing, which works. The problem is I want the user to be able to click one of the words in the combo box and that gets inserted into the text box. This parts not working as the MouseLeftButtonDown is never being fired. I've tried a couple of different methods including the one from this site http://www.designerwpf.com/2008/12/03/getting-a-mouseleftbuttondown-or-mouseleftbuttonup- event-from-your-textbox/

as well as one I saw somewhere else that was combo.MouseLeftButtonDown += delegate { };

Thanks for any help.

A: 

You probably want to look at the SelectionChanged event. It fires whenever an item in the ComboBox's drop down is selected.

I think that the ComboBox internally handles the MouseLeftButtonDown event, and that is causing it not to be passed on to your code.

Andy