当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - 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>
分享给朋友:
您可能感兴趣的文章:
随机阅读: