This is how looks my listbox:
<ListBox x:Name="ForthListBox"
Margin="0,0,-12,0"
ItemsSource="{Binding Tops}"
Tap="ForthListBox_Tap" Style="{StaticResource TopListBoxStyle}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17">
<TextBlock Text="{Binding Title}"
TextWrapping="Wrap"
Margin="12,0,0,0"
FontSize="40"/>
<TextBlock Text="{Binding Rating}"
TextWrapping="NoWrap"
Margin="12,-6,0,0"
Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I edited template for listbox so I have button at the end:
<Style x:Key="TopListBoxStyle" TargetType="ListBox">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<ScrollViewer x:Name="ScrollViewer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" Padding="{TemplateBinding Padding}">
<StackPanel><ItemsPresenter/>
<Button x:Name="BtnLoadMore" Click="BtnLoadMore_Click" Content="Další" />
</StackPanel>
</ScrollViewer>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
And I have ObservableCollection<Top>() in MainViewModel which I Bind to DataContext. It´s okay and it´s showing my items but how can I set that I want show just 50 items in that listbox and after I clicked on button I want to show that first 50 items and 50items more from collection and again and again and where there are no more items in collection which are no shown then hide button. Thanks
Try this sample project. Instead of having listbox vertical offset in this sample , have a button as you wish.
http://blogs.microsoft.co.il/blogs/shair/archive/2011/04/06/wp7-how-to-extend-listbox-when-reaching-last-item.aspx