簡體   English   中英

使用ScrollViewer XAML wp8橫向滾動到末尾

[英]Horizontal scrolling to the end with ScrollViewer XAML wp8

我的XAML中有一個ScrollViewer。 我想將其水平滾動到右側的末尾,以便用戶可以在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>

怎么做?

對於水平滾動,必須使用堆棧面板方向屬性,下面是更新的代碼。

<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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM