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

后端 未结 15 1444
清酒与你
清酒与你 2020-11-27 04:10

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 th

15条回答
  •  天命终不由人
    2020-11-27 04:53

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

        
            
        
    

    And then we select the row in code behind:

        protected void SelectCurrentItem(object sender, KeyboardFocusChangedEventArgs e)
        {
            ListViewItem item = (ListViewItem) sender;
            item.IsSelected = true;
        }
    

提交回复
热议问题