[英]How to get a footer just above a Scrollviewer?
我有一個內部帶有ItemsControl的Scrollviewer。 根據SCItemViewer中的項目數,ItemsControl可以滾動或不滾動。 我有一個控件,顯示所有項目的一些總值。 該控件必須位於ItemsControl下。 如果沒有很多項目,它將位於最后一個項目的下方,而不是頁面的底部,並且它們之間有很大的空間。 我無法做到這一點。 有任何想法嗎? 這是我的一些代碼:
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<DockPanel Grid.Row="0">
<!-- This is my Total Control - just a Border for the example -->
<Grid Margin="0,4" MaxHeight="60" VerticalAlignment="Top" DockPanel.Dock="Bottom">
<Border Background="Red" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</Grid>
<ScrollViewer HorizontalContentAlignment="Stretch" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
>
<ItemsControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding Path=ListeQuestions}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<concUCQuest:UCQuestion HorizontalAlignment="Stretch" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</DockPanel>
我嘗試了DockPanel,將Grid轉換為Grid,但是我沒有想法。
謝謝你的幫助 !
向Scrollviewer添加VerticalAlignment="Stretch"
應該可以解決問題。
<Grid>
<DockPanel LastChildFill="True">
<!-- This is my Total Control - just a Border for the example -->
<Grid DockPanel.Dock="Bottom">
<Border Background="Red" Height="10"/>
</Grid>
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<ItemsControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<ItemsControl.ItemTemplate>
<DataTemplate>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</DockPanel>
</Grid>
這對我有用。
您也可以將ListBox與DataTemplate一起使用,而不是使用ScrollViewer包裝ItemsControl。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.