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
。