简体   繁体   中英

Set focus of items in a combo box

I have a couple of grids in my application and if the combo box that is in grid A has the focus, then A should be visible. Following code totally works fine for Text boxes, and even the combo box, but it doesn't work when I click on the drop down and try to click on an item in the drop down.

<DataTrigger Binding="{Binding IsFocused, ElementName=FwInstances}" Value="True">
 <Setter Property="Visibility" Value="Visible"/>
</DataTrigger>

I am assuming the items in the combo box takes focus when I try to select it? Any explanation on what exactly happens here would be appreciated.

Yes, Focus will be set to Popup content once you open and access the Popup content. So instead of Focused, you could bind to IsKeyBoardFocusWithin property of ComboBox , which remains true, even if you are in Popup.

<DataTrigger Binding="{Binding IsKeyboardFocusWithin,ElementName=FwInstances,Mode=OneWay}" Value="True">
 <Setter Property="Visibility" Value="Visible"/>
</DataTrigger>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM