Answer the question
In order to leave comments, you need to log in
How to make a StackPanel inside a ScrollViewer in WPF (or how else to add a load more button at the bottom of the elements in the ListView)?
This is how I do it:
<ListView.Style>
<Style TargetType="ListView">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListView">
<ScrollViewer x:Name="ScrollViewer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" Padding="{TemplateBinding Padding}">
<StackPanel>
<ItemsPresenter />
<Button Content="More" Name="moreButton"></Button>
</StackPanel>
</ScrollViewer>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.Style>
Answer the question
In order to leave comments, you need to log in
It is not clear from the question that your button should also scroll or should it be fixed there at the bottom of the control?
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<!-- Задаете шаблон отображения -->
<ScrollViewer.Template>
<ControlTemplate TargetType="{x:Type ScrollViewer}">
<Grid>
<ScrollContentPresenter /> <!-- Это область куда помещаются элементы, что будут скролировать -->
<!-- Вместо этого комментария можно поместить кнопку, если не нужно, чтобы она скролировалась -->
<ScrollBar x:Name="PART_VerticalScrollBar" Value="{TemplateBinding VerticalOffset}" Maximum="{TemplateBinding ScrollableHeight}"
ViewportSize="{TemplateBinding ViewportHeight}" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
HorizontalAlignment="Right" Style="{DynamicResource ResourceKey=ScrollBarStyle}" />
</Grid>
</ControlTemplate>
</ScrollViewer.Template>
<!-- А здесь помещаете все, что должно скролироваться -->
</ScrollViewer>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question