I have the following construct, which shows a DataBound ListBox and a Button inside a StackPanel, which again is placed inside a ScrollViewer:
<ScrollViewer VerticalScrollBarVisibility="Visible"
Height="400">
<StackPanel Orientation="Vertical"
MaxHeight="400">
<ListBox x:Name="LbTelEntries"
SelectionChanged="LbTelEntries_SelectionChanged"
MaxHeight="340"
VerticalAlignment="Top"
ItemsSource="{Binding Path=TelItems}">
<ListBox.ItemTemplate>
<DataTemplate>
<Templates:ListBoxItemTemplateSelector Content="{Binding}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button x:Name="BtMoreTelEntries"
Content="More Results"
Click="BtMoreTelEntries_Click"
Visibility="{Binding Path=NumberRemainingResults, Converter={StaticResource NullToVisConverter}}"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Height="70"
Width="410"
Margin="0 0 0 0"
></Button>
</StackPanel>
</ScrollViewer>
My problem is, that the Button should only appear, when the ListBox is scrolled to the end. Once the Button is clicked, the content of the ListBox is exchanged and the Button should again move to the end of the ListBox...
How would I accomplish this?
EDIT: I should mention, that I am also implementing an ItemTemplate. See below:
<DataTemplate x:Key="ListBoxItemVmTemplate">
<Grid DataContext="{Binding}">
<StackPanel Orientation="Horizontal">
<Border x:Name="UpperListBoxTemplateBorder"
Height="42"
Width="44"
BorderBrush="White"
BorderThickness="2.5"
CornerRadius="100"
Margin="10,16,0,0"
VerticalAlignment="Top">
<Path x:Name="DataTemplatePath"
Height="16"
Width="11"
Fill="White"
Stretch="Fill"
Margin="4,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
UseLayoutRounding="False"
Data="M337.59924,129.61948 L337.59924,141.51501 L345.5704,135.87381 z" />
</Border>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="22"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal"
Grid.Row="0">
<Controls:EllipsisTextBlock Text="{Binding DataModel.Title}"
MaxWidth="410"
Margin="18 12 0 0" />
</StackPanel>
<StackPanel Orientation="Horizontal"
Grid.Row="1">
<Controls:EllipsisTextBlock Text="{Binding DataModel.Street}"
FontSize="16"
MaxWidth="410"
Margin="18 -3 0 0" />
<Controls:EllipsisTextBlock Text="{Binding DataModel.ZipCode}"
FontSize="16"
MaxWidth="410"
Margin="18 -3 0 0" />
<Controls:EllipsisTextBlock Text="{Binding DataModel.City}"
FontSize="16"
MaxWidth="410"
Margin="18 -3 0 0" />
</StackPanel>
</Grid>
</StackPanel>
</Grid>
</DataTemplate>