1

I'm trying to create a ListBox, with a dropdown capability, but not ComboBox. Although, if ComboBox can work this way, I don't mind.

I've got a Button, and a TextBlock below it:

button and textblock

The user can select multiple files, which are then added to a List. When the "files selected" TextBlock is clicked, I want to show a drop-down, showing the names of the files, and a button to remove a file from selection next to the name, which I can best describe as a Dropdown ListBox.

I've tried using a ComboBox with DataTemplate. The only drawback was that I don't like how it looks, and that it selects and item (e.g. changes the "# files selected" text), if I click anything but the remove button.

Gregor Menih
  • 5,036
  • 14
  • 44
  • 66
  • You can also use ControlTemplate (of the ComboBox) to let it appear differently (because you don't like its current appearance): http://stackoverflow.com/questions/16392670/custom-combobox-in-wpf-application contains an example. – Sjips Nov 25 '14 at 18:41
  • Sounds like an `Expander` to me. Have you tried that? – BradleyDotNET Nov 25 '14 at 18:44

1 Answers1

0

All a combobox is is a panel, so just create your own panel with the controls that you need and display it below the textbox when it is clicked. Don't worry about trying to reuse an existing control if it doesn't work for you. That's what makes WPF so great; it can be molded to your needs

Justin Pihony
  • 66,056
  • 18
  • 147
  • 180
  • Alright, but how do I make the panel appear above other controls, without changing the position of them? – Gregor Menih Nov 25 '14 at 18:46
  • http://stackoverflow.com/questions/5450985/how-to-make-overlay-control-above-all-other-controls has the answers to that. The gist is that you can put multiple items in a grid cell and they are rendered using their z-index – Justin Pihony Nov 25 '14 at 18:48