2010-11-03 38 views
1

下面的XAML正常工作:的Silverlight:困難的ScrollViewer(再次)

<Grid x:Name="LayoutRoot" Background="Transparent"> 
     <ListBox x:Name="StoryListBox"/> 
</Grid> 

ListBox進行相應滾動時有太多的內容,以適應在一個屏幕上。

但是,我修改XAML如下,它打破:

<Grid x:Name="LayoutRoot" Background="Transparent"> 

    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto" /> 
     <RowDefinition Height="*" /> 
    </Grid.RowDefinitions> 

    <TextBox x:Name="LoadingMessage" Text="Loading..." Grid.Row="0" /> 
    <ListBox x:Name="StoryListBox" Grid.Row="0" /> 
    <Button x:Name="LoadMoreStories" Content="Load More Stories" Grid.Row="1" Visibility="Collapsed"/> 

</Grid> 

現在,ListBox只有向下滾動一點點,即使它已經溢出的內容。

我怎麼搞砸了?

更新:我也試過以下,但它仍然不能正常工作:

<Grid x:Name="LayoutRoot" Background="Transparent"> 

    <StackPanel x:Name="Loading"> 
     <TextBox Text="Loading..." /> 
     <ProgressBar IsIndeterminate="True" Style="{StaticResource PerformanceProgressBar}" /> 
    </StackPanel> 

    <ScrollViewer> 
     <StackPanel> 
      <ListBox x:Name="StoryListBox" /> 
      <Button x:Name="LoadMoreStories" Content="Load More Stories" Visibility="Collapsed"/> 
     </StackPanel> 
    </ScrollViewer> 

</Grid> 

它的ListBox只有向下滾動一點點相同的問題。

+0

這裏它似乎沒有問題。你可以發佈一個獨立的樣本(例如樣本數據)嗎? – robertos 2010-11-03 20:13:19

回答

2

試試這個

<Grid.RowDefinitions> 
     <RowDefinition /> 
     <RowDefinition Height="Auto" /> 
    </Grid.RowDefinitions> 
+0

只需要注意這個解決方案,「加載更多」按鈕將始終在屏幕的底部。 – 2010-11-03 22:28:39

+0

我想在用戶滾動瀏覽所有內容後,將「加載更多」按鈕放在所有內容的底部。 – 2010-11-04 03:29:33

0

它滾動正常,但列表框的大小比頁大。嘗試設置大小明確。

  <StackPanel Orientation="Horizontal" Height="500"> 
      <TextBox x:Name="LoadingMessage" Text="Loading..." Grid.Row="0" /> 
      <ListBox x:Name="StoryListBox" Grid.Row="0" > 
       <ListBoxItem Content="a"></ListBoxItem> 
       <ListBoxItem Content="b"></ListBoxItem> 
       <ListBoxItem Content="c"></ListBoxItem> 
       <ListBoxItem Content="d"></ListBoxItem> 
       <ListBoxItem Content="e"></ListBoxItem> 
       <ListBoxItem Content="f"></ListBoxItem> 
       <ListBoxItem Content="g"></ListBoxItem> 
       <ListBoxItem Content="h"></ListBoxItem> 
       <ListBoxItem Content="i"></ListBoxItem> 
       <ListBoxItem Content="j"></ListBoxItem> 
       <ListBoxItem Content="k"></ListBoxItem> 
       <ListBoxItem Content="l"></ListBoxItem> 
       <ListBoxItem Content="1"></ListBoxItem> 
       <ListBoxItem Content="2"></ListBoxItem> 
       <ListBoxItem Content="3"></ListBoxItem> 
       <ListBoxItem Content="4"></ListBoxItem> 
       <ListBoxItem Content="5"></ListBoxItem> 
       <ListBoxItem Content="6"></ListBoxItem> 
       <ListBoxItem Content="7"></ListBoxItem> 
       <ListBoxItem Content="8"></ListBoxItem> 
       <ListBoxItem Content="9"></ListBoxItem> 
       <ListBoxItem Content="10"></ListBoxItem> 
       <ListBoxItem Content="11"></ListBoxItem> 
       <ListBoxItem Content="12"></ListBoxItem> 
       <ListBoxItem Content="13"></ListBoxItem> 
       <ListBoxItem Content="14"></ListBoxItem> 
      </ListBox> 
      </StackPanel>