How to make two controls look like focus?

I am trying to write my own control that has a TextBox and a ListBox inside it. But I found that when I enter text in a TextBox (so that the TextBox has focus), the ListBox appears as unfocused. This makes my control look like two different controls.

I read on MSDN that there is something called FocusScope in WPF, but I failed.

So my question is: how can I get the ListBox and TextBox controls to focus when one of them has keyboard focus?

+4
source share
1 answer

Set the IsFocusScope property for the environment (here: StackPanel): ListBox and TextBox are processed together with respect to focus

  <StackPanel FocusManager.IsFocusScope="True"> <ListBox > <ListBoxItem>Item1</ListBoxItem> <ListBoxItem>Item2</ListBoxItem> </ListBox> <TextBox>Enter Text here...</TextBox> </StackPanel> 
0
source

Source: https://habr.com/ru/post/1390265/


All Articles