Select ListBoxItem if TextBox in ItemTemplate gets focus

后端 未结 3 1016
情深已故
情深已故 2020-11-30 12:56

I have added a DataTemplate to a ListBox class to bind my collection to:



        
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 13:25

    You can trigger on the property IsKeyboardFocusWithin in the ItemContainerStyle and set IsSelected to true.

    
        
    
    

    You could also use a Setter instead of a single frame animation but then the selection will be lost again once the focus leaves the ListBox:

    
        
    
    

提交回复
热议问题