我有一个包含一些用户控件的主窗口,如下所示
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0">
<controls:FileControl x:Name="FileControl" />
<controls:FControl x:Name="FControl"/>
</StackPanel>
<controls:MessagesControl Grid.Row="1" x:Name="MessagesControl" />
</Grid>
现在在FControl中,我有一个堆栈面板,其中包括许多控件,如下面,还有一个列表框,在文本框中键入内容时可以看到该框,就像自动完成一样。
<Expander>
<StackPanel>
<textBox></textBox>
<ComboBox></ComboBox>
<ListBox Panel.ZIndex="100" ItemsSource="{Binding Collection}" SelectedIndex="{Binding Path=SelectedItemIndex, Mode=TwoWay}" Visibility="{Binding VisibiltyAttr}" HorizontalAlignment="Center" VerticalAlignment="Bottom">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonUp">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource AncestorType=ItemsControl},
Path=DataContext.SelectionCommand}" CommandParameter="{Binding}"></i:InvokeCommandAction>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Expander>
现在的问题是,此列表框在窗口中可见时正在占用空间。我想显示此列表框,以显示在所有控件之上,包括在主窗口上的其他用户控件。 如何显示此ListBox与其他控件重叠。请提出解决方案,我在listbox上尝试了z-index,但没有用。