使用ScrollViewer XAML wp8水平滚动到最后
本文关键字:滚动 最后 水平 wp8 ScrollViewer XAML 使用 | 更新日期: 2023-09-27 18:02:17
我有一个ScrollViewer在我的XAML。我想把它水平滚动到右边的末端,这样用户就可以看到ScrollViewer中的所有控件。
下面是我的代码:
<ScrollViewer x:Name="ScrollFilter" HorizontalScrollBarVisibility="Auto" HorizontalScrollMode="Enabled">
<StackPanel HorizontalAlignment="Left">
<Rectangle x:Name="RecAntiqueFilter" Fill="Red" Height="100" Width="100" DoubleTapped="RecAntiqueFilter_DoubleTapped" Tapped="RecAntiqueFilter_Tapped"/>
<Rectangle x:Name="RecBlurFilter" Fill="Green" Height="100" Width="100" Margin="0,-100,-200,0" Tapped="RecBlurFilter_Tapped"/>
<Rectangle x:Name="RecHSTFilter" Fill="Blue" Height="100" Width="100" Margin="0,-100,-400,0" Tapped="RecHSTFilter_Tapped"/>
<Rectangle x:Name="RecBFilter" Fill="Green" Height="100" Width="100" Margin="0,-100,-600,0" Tapped="RecBlurFilter_Tapped"/>
<Rectangle x:Name="RecHFilter" Fill="Blue" Height="100" Width="100" Margin="0,-100,-800,0" Tapped="RecHSTFilter_Tapped"/>
<Rectangle x:Name="RecFilter" Fill="Green" Height="100" Width="100" Margin="0,-100,-1000,0" Tapped="RecBlurFilter_Tapped"/>
<Rectangle x:Name="RecHcFilter" Fill="Yellow" Height="100" Width="100" Margin="0,-100,-1200,0" Tapped="RecHSTFilter_Tapped"/>
<Rectangle x:Name="RecFake" Fill="Transparent" Height="100" Width="400" Margin="0,-100,-1400,0"/>
</StackPanel>
</ScrollViewer>
怎么做?
对于水平滚动,必须使用stack panel orientation属性,更新代码如下:
<ScrollViewer x:Name="ScrollFilter" HorizontalScrollBarVisibility="Auto" HorizontalScrollMode="Enabled">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Rectangle x:Name="RecAntiqueFilter" Fill="Red" Height="100" Width="100" DoubleTapped="RecAntiqueFilter_DoubleTapped" Tapped="RecAntiqueFilter_Tapped"/>
<Rectangle x:Name="RecBlurFilter" Fill="Green" Height="100" Width="100" Margin="0,-100,-200,0" Tapped="RecBlurFilter_Tapped"/>
<Rectangle x:Name="RecHSTFilter" Fill="Blue" Height="100" Width="100" Margin="0,-100,-400,0" Tapped="RecHSTFilter_Tapped"/>
<Rectangle x:Name="RecBFilter" Fill="Green" Height="100" Width="100" Margin="0,-100,-600,0" Tapped="RecBlurFilter_Tapped"/>
<Rectangle x:Name="RecHFilter" Fill="Blue" Height="100" Width="100" Margin="0,-100,-800,0" Tapped="RecHSTFilter_Tapped"/>
<Rectangle x:Name="RecFilter" Fill="Green" Height="100" Width="100" Margin="0,-100,-1000,0" Tapped="RecBlurFilter_Tapped"/>
<Rectangle x:Name="RecHcFilter" Fill="Yellow" Height="100" Width="100" Margin="0,-100,-1200,0" Tapped="RecHSTFilter_Tapped"/>
<Rectangle x:Name="RecFake" Fill="Transparent" Height="100" Width="400" Margin="0,-100,-1400,0"/>
</StackPanel>
</ScrollViewer>