我在滚动查看器中有一个列表框,我想在向上/向下滚动时更改列表框的高度。当我向下滚动时,列表框的高度应该增加,反之亦然
这就是我的表现:
private void OnScrollbarValueChanged(object sender,RoutedPropertyChangedEventArgs<double> e)
{
listbox.Height += e.NewValue - e.OldValue;
}
然而,这是为了我的目的,但看起来很落后。当我滚动并且高度改变时,有很多口吃。无论如何要放开口吃/滞后并使这种高度变化滞后?
答案 0 :(得分:0)
所以我发现example如何在Windows手机中实现视差效果,我稍微修改了一下。
这是XML,我认为它正是你想要的。
<Grid x:Name="LayoutRoot"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid x:Name="ImageContainer"
VerticalAlignment="Top"
CacheMode="BitmapCache"
RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<CompositeTransform x:Name="ImageTransform" />
</Grid.RenderTransform>
<Image Source="/Assets/chitanda.jpg"
Stretch="None"
HorizontalAlignment="Center"
VerticalAlignment="Top"
x:Name="Image" />
</Grid>
<ScrollViewer x:Name="Scroller" Margin="0,300,0,0"
ManipulationMode="Control"
Background="#33000000">
<Grid x:Name="ScrollGrid" Margin="0,-300,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="500" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel x:Name="TitlePanel"
VerticalAlignment="Bottom"
Margin="0,0,0,24">
<TextBlock Style="{StaticResource PhoneTextTitle1Style}"
Margin="24,0"
TextWrapping="Wrap"
Text="Title" />
</StackPanel>
<ListBox x:Name="ListBox1" Grid.Row="1" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</ScrollViewer>
</Grid>
<Grid Grid.Row="1">
<TextBlock Text="Static TextBox on the bottom" HorizontalAlignment="Center"/>
</Grid>
</Grid>
为了避免滚动中的冲突,我在ListBox中禁用它。代码隐藏完全相同。我希望这就是你要找的东西。快乐的编码(: