2011-05-19 103 views
1

我试图创建一个ComboBox,它既是可编辑的,也是下降的而不是向下的。按下向上箭头键(默认为关闭)时,菜单也应该打开。WPF:可编辑的组合框,下降?

我已经尝试修改ComboBox的默认ControlTemplate,但它似乎没有任何IsEditable的支持?

回答

1

默认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