开发者

WPF ComboBox with editable textbox as an item

开发者 https://www.devze.com 2023-03-23 23:32 出处:网络
I\'m looking to have a combo box with only two items: ---------开发者_Python百科-- |Other.. | ------------

I'm looking to have a combo box with only two items:

---------开发者_Python百科--
|  Other.. |
------------
|  TextBox |
------------

Text Box representing a physical textbox that can be editable and Other.. being just a regular combobox item.

Can someone help me out on how I will need to edit it.

I have tried changing the Combbox.itemtemplate with a stackpanel and then adding a textbox, but it didn't show up and that also stops the chance of me having a regular combobox item in the control.

Thanks in advance.


Have you tried setting ComboBox.IsEditable = true? Then you'll need just one item and the ComboBox.Text property.


Not quite sure what the problem is, have you tried this:

<ComboBox>
    <ComboBoxItem>Other</ComboBoxItem>
    <TextBox>TextBox</TextBox>
</ComboBox>

If this is not what you want, please explain what exactly you need...


(The TextBox-item might be quite hard to select so giving it a label which can be clicked might be of interest)

<ComboBox>
    <ComboBoxItem>Normal Item</ComboBoxItem>
    <StackPanel Orientation="Horizontal">
        <TextBlock Text="Other: " VerticalAlignment="Center"/>
        <TextBox>Enter text...</TextBox>
    </StackPanel>
</ComboBox>
0

精彩评论

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