Home > Software engineering >  How to hide arrow button in combobox?
How to hide arrow button in combobox?

Time:11-26

Now I just want to dropdown the combobox via code.

IsDropDownOpen = true;

So how to hide (not disable) the arrow button in combobox?

enter image description here

CodePudding user response:

To hide the ComboBoxToggleButton, you would have to edit a copy of the combobox template.

Right click on the combobox and select edit template. Select edit a copy and give it a name. (You may want to put the copy in a resource dictionary of it's own considering the content size)

The generated ComboBox style will have reference to two templates, ComboBoxTemplate and ComboBoxEditableTemplate.

In each template, you will find a ToggleButton with x:Name:toggleButton, that is the toggle button you want to hide.

You can remove it entirely, or make use of your WPF given Visibility property. Your call ;)

CodePudding user response:

I would consider putting a textbox on top of the combobox and hiding that part of it. Something like:

<Grid>
    <ComboBox Name="YourCombo"/>
    <TextBox Name="VisibleValueTextBox"/>
</Grid>

You can bind the text of VisibleValueTextBox to that of YourCombo. When you drop it down, the dropdown will still be on top of everything.

I'm not sure what your full requirements are but this is a quick and perhaps rather dirty approach which could work.

  • Related