【发布时间】:2015-09-18 09:45:43
【问题描述】:
我有一个带有扩展器的列表框,而扩展器又包含一个列表框。 我希望 ListBox with Expanders (listBox1) 和每个 Expander (listBox2) 内的 ListBox 都具有滚动功能,但我无法让最里面的滚动工作(即我的 XAML 中的 scrollViewer1)。
如何让两个滚动条都工作?
<ScrollViewer x:Name="scrollViewer1">
<ListBox x:Name="listBox1" ItemsSource="{Binding Data}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Expander>
<Expander.Header>
<TextBlock Text="{Binding Name}">
</TextBlock>
</Expander.Header>
<ScrollViewer x:Name="scrollViewer2">
<ListBox x:Name="listBox2" ItemsSource="{Binding Numbers}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Grid>
<TextBlock Grid.Column="0" Text="{Binding}"/>
</Grid>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
</Expander>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
【问题讨论】:
标签: .net wpf xaml scrollviewer expander