2011-11-30 92 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,然後滾動條不會顯示在其中。