WPF:可编辑的组合框掉落? [英] WPF: Editable ComboBox that drops up?
问题描述
我正在尝试创建一个既可编辑又可下拉而不是下拉的组合框.按向上箭头键(默认为向下)时,菜单也应该打开.
Im trying to create a ComboBox thats both editable and drops up instead of down. The menu should also open when pressing the up-arrow-key (down by default).
我尝试修改 ComboBox 的默认 ControlTemplate,但它似乎不支持 IsEditable?
I have tried modifying the default ControlTemplate for ComboBox but it doesn't seem to have any support for IsEditable?
推荐答案
默认的 ControlTemplate
不适用于 IsEditable = true
品种,但该样式包含一个触发器设置 IsEditable 时更改它:
The default ControlTemplate
is not for the IsEditable = true
variety, but the style contains a trigger that changes it when IsEditable is set:
<Style.Triggers>
<Trigger Property="IsEditable" Value="true">
<Setter Property="BorderBrush" Value="{StaticResource TextBoxBorder}"/>
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Padding" Value="3"/>
<Setter Property="Template" Value="{StaticResource ComboBoxEditableTemplate}"/>
</Trigger>
</Style.Triggers>
它将其更改为另一个 ControlTemplate
,其中相关部分是弹出窗口:
It changes it to another ControlTemplate
where the relevant part is the popup:
<Popup x:Name="PART_Popup"
AllowsTransparency="true"
Grid.ColumnSpan="2"
IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"
Placement="Bottom">
...
</Popup>
我认为您应该能够将 Placement
属性更改为 Top
.
I think you should just be able to change the Placement
property to Top
.
这篇关于WPF:可编辑的组合框掉落?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!