0

I'm looking to create a UI element in a WPF XAML UserControl with something that looks and works roughly like Google Suggest - a TextBox with a ListBox that appears beneath it showing suggestions that match the text entered in the TextBox. In simplified form, my XAML looks like this:

<StackPanel>
    [...controls above...]
    <TextBox ... />
    <ListBox ItemsSource="{Binding SearchHints}"
             Visibility="{Binding HasSearchHints}" MaxHeight="100" />
    [...controls below...]
</StackPanel>

What I'm struggling to achieve is I want the ListBox to float above any content that may come below it, much like the dropdown part of a ComboBox does. Currently it pushes any controls below it downwards. I figure this must be possible because the ComboBox control essentially does exactly what I want to do. In CSS it would be a matter of setting the element to position:relative but there doesn't seem to be an immediately obvious equivalent in XAML. Any ideas?

wwarby
  • 1,873
  • 1
  • 21
  • 37
  • 1
    Put your ListBox inside a Popup, or use the controls that are made for this like AutoCompleteBox http://stackoverflow.com/questions/2338690/wpf-autocomplete-textbox-again – Icepickle Mar 20 '15 at 09:39
  • Sweet - that's exactly the solution I was looking for, thanks! – wwarby Mar 20 '15 at 14:16

1 Answers1

0

Used Icepickle's comment - the element did exactly what I wanted.

wwarby
  • 1,873
  • 1
  • 21
  • 37