2011-11-30 54 views
2

我有一个listbox内的列表框,当我尝试降低窗口的高度列表框的滚动条不出现。我想显示外部列表框上的滚动条,因为outerlistbox可以有多个innner列表框。 这里是我正在使用的XAML。任何人都可以让我知道是什么问题?嵌套列表框滚动问题

<ListBox Name="MasterListBox" HorizontalAlignment="Stretch" Width="200"> 
    <ListBoxItem > 
     <ListBox Name="Child1" BorderBrush="{x:Null}"> 
      <ListBoxItem Content="testing item1" /> 
      <ListBoxItem Content="testing item2" /> 
      <ListBoxItem Content="testing item3" /> 
      <ListBoxItem Content="testing item1" /> 
      <ListBoxItem Content="testing item2" /> 
      <ListBoxItem Content="testing item3" /> 
      <ListBoxItem Content="testing item1" /> 
      <ListBoxItem Content="testing item2" /> 
      <ListBoxItem Content="testing item3" /> 
      <ListBoxItem Content="testing item1" /> 
      <ListBoxItem Content="testing item2" /> 
      <ListBoxItem Content="testing item3" /> 
      <ListBoxItem Content="testing item1" /> 
      <ListBoxItem Content="testing item2" /> 
      <ListBoxItem Content="testing item3" /> 
      <ListBoxItem Content="testing item1" /> 
      <ListBoxItem Content="testing item2" /> 
      <ListBoxItem Content="testing item3" /> 
     </ListBox> 
    </ListBoxItem> 

</ListBox> 

回答

1

如果我对你有用,你不想让内部列表框滚动。

有两种方法可以实现的是:

1)更改内部列表框中ItemsPanel。 2)如果你真的需要保留内控件作为列表框,你必须用内置列表框控件的模板中的ContentPresenter替换ScrollViewer。看到这个链接(它被标记为正确答案)>http://forums.silverlight.net/t/193872.aspx/1

+0

如果我使用下面的URL中提到的样式,它会给我一个编译时错误,因为内容演示者不支持直接内容 – andy

0

将您的内心listbox更改为ItemsControl,然后滚动条不会显示在其中。