Selecting a Textbox Item in a Listbox does not change the selected item of the listbox


I Have a wpf Listbox that display's a list of textboxes. When I click on the Textbox the Listbox selection does not change. I have to click next to the TextBox to select the listbox item. Is there some property I need to set for the Textbox to forward the click event to the Listbox?

1/11/2019 6:33:39 AM

We use the following style to set a PreviewGotKeyboardFocus which handles all events of TextBox control and ComboBoxes and such:

        <Style TargetType="ListViewItem">
            <EventSetter Event="PreviewGotKeyboardFocus" Handler="SelectCurrentItem"/>

And then we select the row in code behind:

    protected void SelectCurrentItem(object sender, KeyboardFocusChangedEventArgs e)
        ListViewItem item = (ListViewItem) sender;
        item.IsSelected = true;
12/14/2009 8:42:22 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow