2011-01-07 88 views
2

我正在爲WP7構建Silverlight應用程序。我有一個ListBoxPivotItem與一些內容。我想要ListBox滾動顯示所有內容。不幸的是,用戶不能一直向下滾動 - 最後的項目被切斷。Silverlight:運行關閉頁面的內容

這裏是XAML:

<controls:Pivot Title="SECTIONS" x:Name="pivotControl" ItemsSource="{Binding SectionViewModels}"> 
     <controls:Pivot.HeaderTemplate> 
      <DataTemplate> 
       <TextBlock Text="{Binding DisplayName}" /> 
      </DataTemplate> 
     </controls:Pivot.HeaderTemplate> 
     <controls:Pivot.ItemTemplate> 
      <DataTemplate> 
       <StackPanel> 
        <TextBlock Style="{StaticResource disabledText}" Visibility="{Binding NoStoryContent}"> 
         Content could not be downloaded from MySite.com. Do you have a network connection? 
        </TextBlock> 

        <!-- fake data to demonstrate --> 
        <ListBox FontSize="100"> 
         <ListBoxItem Content="A" /> 
         <ListBoxItem Content="B" /> 
         <ListBoxItem Content="C" /> 
         <ListBoxItem Content="D" /> 
         <ListBoxItem Content="E" /> 
         <!-- the user can scroll no lower than the top half of the 'F' --> 
         <ListBoxItem Content="F" /> 
         <ListBoxItem Content="G" /> 
        </ListBox> 

       </StackPanel> 
      </DataTemplate> 
     </controls:Pivot.ItemTemplate> 
    </controls:Pivot> 
從滾動發行

除此之外,一切看起來/正常工作與此控件。

我會做什麼錯?

更新:它工作正常,如果我明確指定的高度。

+0

你看過scrollviewer(http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.aspx)和這個問題(http://stackoverflow.com/questions/472796) /如何獲得垂直滾動條在我的列表框中) – Eugene 2011-01-07 22:53:21

回答

0

我沒有使用數據透視控件,所以我不確定這是否是您需要的,但我會先嚐試包含列表框的ScrollViewer。

+0

ListBox已經在ScrollViewer中呈現其內容。 – AnthonyWJones 2011-01-08 16:11:55

0

問題是您在使用Grid時正在使用StackPanel

 <controls:Pivot.ItemTemplate> 
      <DataTemplate> 
       <Grid> 
        <TextBlock Style="{StaticResource disabledText}" Visibility="{Binding NoStoryContent}"> 
         Content could not be downloaded from MySite.com. Do you have a network connection? 
        </TextBlock> 

        <!-- fake data to demonstrate --> 
        <ListBox FontSize="100"> 
         <ListBoxItem Content="A" /> 
         <ListBoxItem Content="B" /> 
         <ListBoxItem Content="C" /> 
         <ListBoxItem Content="D" /> 
         <ListBoxItem Content="E" /> 
         <!-- the user can scroll no lower than the top half of the 'F' --> 
         <ListBoxItem Content="F" /> 
         <ListBoxItem Content="G" /> 
        </ListBox> 

       </Grid> 
      </DataTemplate> 
     </controls:Pivot.ItemTemplate> 

現在它按預期滾動。

+0

爲什麼`Grid`在這方面的行爲與`StackPanel`不同? – 2011-01-08 19:38:50