当它获得焦点时展开组合框及其项目 [英] Expand the combobox and its items when it gets focus
问题描述
我想在组合框获得焦点时扩展组合框的高度.
I want to expand the height of the combobox whenever the combobox gets the Focus.
我使用以下代码来扩展组合框高度.
I have used the following code to expand the combobox height.
<Style TargetType="{x:Type ComboBox}">
<Style.Triggers>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="1" ScaleY="2" />
</Setter.Value>
</Setter>
<Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
<Setter Property="Panel.ZIndex" Value="99999"/>
</Trigger>
</Style.Triggers>
</Style>
问题:
当我第一次将焦点放在组合框上时,组合框项目列表以正常模式打开.但是,如果我再次单击组合框,则会打开组合框项目列表,并展开列表项目高度.
When i put the focus on the Combobox first time, the combobox item list opened in normal mode. But if i again click on the combobox then combobx item list opened and also list items height is expanded.
但我希望组合框列表项即使在第一次单击(焦点)时也能展开.即使我选择了组合框项目中的项目,组合框高度也必须处于展开模式.
But i want the combobox list items to be expanded even in the first click (focus) also. Also combobox height must be in expanded mode even when i select the item in the Combobox item.
提前致谢
推荐答案
这是您想要的吗?
<Style TargetType="{x:Type ComboBox}">
<Style.Triggers>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="IsDropDownOpen" Value="true" />
</Trigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
这篇关于当它获得焦点时展开组合框及其项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!