1
我试图创建一个ComboBox,它既是可编辑的,也是下降的而不是向下的。按下向上箭头键(默认为关闭)时,菜单也应该打开。WPF:可编辑的组合框,下降?
我已经尝试修改ComboBox的默认ControlTemplate,但它似乎没有任何IsEditable的支持?
我试图创建一个ComboBox,它既是可编辑的,也是下降的而不是向下的。按下向上箭头键(默认为关闭)时,菜单也应该打开。WPF:可编辑的组合框,下降?
我已经尝试修改ComboBox的默认ControlTemplate,但它似乎没有任何IsEditable的支持?
默认ControlTemplate
不是为IsEditable = true
品种,但风格包含了更改它,当IsEditable设置一个触发:
<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
其中相关部分是弹出:
<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
。