WPF:掉落的可编辑组合框? [英] WPF: Editable ComboBox that drops up?
问题描述
我正在尝试创建一个既可编辑又可下拉而不是下拉的ComboBox。按下向上箭头键(默认为向下)时,菜单也应该打开。
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>
我认为您应该可以更改展示位置
属性设置为顶部
。
I think you should just be able to change the Placement
property to Top
.
这篇关于WPF:掉落的可编辑组合框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!