我有一個通用應用以下安裝 -鋼釘元件中的ScrollViewer同時加入內容
<ScrollViewer x:Name="ContentScrollViewer"
Grid.Row="1"
BringIntoViewOnFocusChange="False">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ListView x:Name="TopContent" HorizontalAlignment="Stretch" />
<Grid x:Name="ContentToPin" Grid.Row="1" Height="400" />
<ListView x:Name="BottomContent" Grid.Row="2" HorizontalAlignment="Stretch" />
</Grid>
</ScrollViewer>
當既不載入列表視圖填充和ContentToPin與屏幕的頂部正確對齊。但是,當我開始填充TopContent listview時,ContentToPin元素被按下屏幕。
| | <- TopContent ListView populated off screen.
| |
------------------------- <-Top of screen
| |
| | <- ContentToPin
| |
所以TopContent加載屏幕外,指示器然後顯示在ContentToPin指示更多的內容是上述可用,因此用戶可以向下平移,以查看TopContent。
什麼是最好的方式來填充TopContent ListView,同時保持ContentToPin的頂部邊緣到頁面的頂部?
*注意我不想爲TopContent ListView設置高度。
我試圖在TopContent ListView上使用SizeChanged事件處理函數來調整ScrollViewers的位置,但這只是產生一個生澀的行爲。
private void TopContentListViewOnSizeChanged(object sender, SizeChangedEventArgs e)
{
var heightChange = e.NewSize.Height - e.PreviousSize.Height;
this.ContentScrollViewer.ChangeView(
null,
this.ContentScrollViewer.VerticalOffset + heightChange,
null,
false);
}
你想讓scrollviewer向上擴展可滾動區域,同時保持它位於「ContentToPin」?你是否做到了這一點,而不是生澀? –