2010-07-30 42 views
0

下移溢出內容我有一個列表框擴展:水平的StackPanel

<ListBox ItemsSource="{Binding MySource"> 
    <ListBox.ItemTemplate> 
     <DataTemplate> 
      <RadioButton Content="{Binding MyContent}" /> 
     </DataTemplate> 
    </ListBox.ItemTemplate> 
    <ListBox.ItemsPanel> 
     <ItemsPanelTemplate> 
      <StackPanel Orientation="Horizontal" /> 
     </ItemsPanelTemplate> 
    </ListBox.ItemsPanel> 
</ListBox> 

我纏上水平方向的StackPanel的單選按鈕。我希望溢出單選按鈕向下移動(如下圖所示的右圖)(無水平滾動條)。現在,我就像左邊那個。

Stackpanel Orientation="Horizontal" http://www.empirepic.com/images/i8f5sevyzqch10uodso.jpg

回答

2

你需要使用一個WrapPanel,不是一個StackPanel。在WPF中它被構建到主要程序集中,但在Silverlight中,您需要獲得Silverlight Toolkit

<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding MySource"> 
    <ListBox.ItemTemplate> 
     <DataTemplate> 
      <RadioButton Content="{Binding MyContent}" /> 
     </DataTemplate> 
    </ListBox.ItemTemplate> 
    <ListBox.ItemsPanel> 
     <ItemsPanelTemplate> 
      <t:WrapPanel /> 
     </ItemsPanelTemplate> 
    </ListBox.ItemsPanel> 
</ListBox> 
+0

ScrollViewer.Horizo​​ntalScrollBarVisibilityProperty應該是ScrollViewer.Horizo​​ntalScrollBarVisibility。其餘的完美!謝謝,喬希! – 2010-07-30 03:11:22

+0

這就是我懶惰和複製和粘貼名稱。 :)謝謝你的擡頭。 – Josh 2010-07-30 13:36:36