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

后端 未结 15 1390
清酒与你
清酒与你 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:56

    I don't have enough reps to comment, so I am posting my comment as answer. Grazer's solution above does not work in cases where you have another control such as a Button that needs the SelectedItem. This is because as per the Style Trigger, the IsKeyboardFocusWithin becomes false when you click on that Button, and the SelectedItem becomes null.

提交回复
热议问题