sandy
sandy

Reputation: 913

Overlay WPF controls

I've written an 'auto-suggest' textbox user control in WPF. It behaves a little bit like the 'To' list in Hotmail, allowing the user to enter a list of items, offering suggestions when it is able.

The main controls are a a text box, a wrap panel and a list box. The text box captures user input. The wrap panel contains the text box and shows previous entries. The list box is used to show suggestions. Most of the time, the list box is hidden.

I'm using multiple instances of my control in a stack panel.

My problem is that when the list box is shown, it is included in the measurement of the height of the control. This forces the following controls in the stack panel to be shifted down, as these pictures demonstrate:

alt text http://img13.imageshack.us/img13/8366/example1a.png

alt text http://img208.imageshack.us/img208/7664/example2a.png

I've tried overriding the measurement of my control so not to include the list box, but this just results in the list box not being visible.

What I want to do is make the list box overlay any subsequent controls in the stack panel, like a combo box's drop down would do. However, I really don't know how to do this. Any ideas?

Thanks

Sandy

Upvotes: 3

Views: 2297

Answers (2)

gehho
gehho

Reputation: 9248

You might want to have a look at the Popup control. That is what the ComboBox uses to display its options. Good luck!

Upvotes: 4

Aviad P.
Aviad P.

Reputation: 32669

Try this instead of your text box / list box combination: A Reusable WPF Autocomplete TextBox

Upvotes: 1

Related Questions