Lets say I have a list of custom control:
<ItemsControl>
<ItemsControl.ItemTemplate>
<DataTemplate>
<ctrl:AutoCompleteTextBox />
</DataTemplate>
</ItemsControl.ItemTemplate>
</StackPanel>
These controls are autocomplete text boxes and I want the suggestions list to be rendered above the rest of the controls.
If I design my control like this:
<UserControl>
<StackPanel Orientation="Vertical">
<TextBox Name="Value" />
<ListView Name="Suggestions" />
</StackPanel>
</UserControl>
When I populate my ListView, the stackpanel grows and the other autocomplete are just shifted. I want them to be covered by the suggestions list.
I tried to use a Canvas with Panel.ZIndex property set to 2000, but the canvas is always rendered below the other items:
Here is the xaml:
<UserControl>
<StackPanel Orientation="Vertical">
<TextBox Name="Value" />
<Canvas Panel.ZIndex="2000">
<ListView Panel.ZIndex="2000" Name="Suggestions" />
</Canvas>
</StackPanel>
</UserControl>
I also tried to use a PopUp. It works well except that the popup is rendered on top of the screen, even if another application got the focus:
Here is the xaml:
<UserControl>
<StackPanel Orientation="Vertical">
<TextBox Name="Value" />
<PopUp IsOpen="false">
<ListView Name="Suggestions" />
</PopUp>
</StackPanel>
</UserControl>
I am open to any other solution, if it applies to my initial requirement.