user280498
user280498

Reputation: 201

Assign shortcut to item in WPF ComboBox

I want to assign the shortcut to every item in combobox control. Also I want the shortcut "letter" is underlined (for label/textbox pair I would use the _ symbol to achieve the desired effect).

For example, there is a combobox containing names: Alex, John, Sandra. I want press lets say Alt+e for selecting Alex, Alt+o for selecting John and Alt+a for Sandra. Is it doable without creating my own control?

Upvotes: 1

Views: 351

Answers (1)

paparazzo
paparazzo

Reputation: 45096

This is the ListBox version.

    <ListBox>
        <ListBoxItem>
            <Button Click="btnAlpha_Click">
                <AccessText>_alpha</AccessText>
            </Button>
        </ListBoxItem>
        <ListBoxItem>
            <Button Click="btnBravo_Click">
                <AccessText>_beta</AccessText>
            </Button>
        </ListBoxItem>
        <ListBoxItem>
            <Button Click="btnCharlie_Click">
                <AccessText>_charlie</AccessText>
            </Button>
        </ListBoxItem>
    </ListBox>

Upvotes: 1

Related Questions