开发者

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).

I have tried modifying the default ControlTemplate for ComboBox but it does开发者_如何学Gon't seem to have any support for 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>

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜