Scrollviewer平移触摸位置

时间:2015-04-14 18:43:23

标签: c# wpf xaml

我有一个scrollviewer,其中有2个WrapPanel。我想知道一旦用户滚动到最后一个面板的最后一端,我将如何获得滚动查看器位置。我试图显示和隐藏一个屏幕上的箭头,表示有更多的内容,但是在屏幕右侧,但是我想在它们到达滚动查看器的末尾时隐藏按钮。

有人能指出我将在后面的代码中做什么,以获得基于平移的scrollviewer的水平偏移位置。主要是我希望得到最右边的位置,并在到达那一点时隐藏箭头按钮。我的每个面板的宽度目前是1920,所以窗口当前是1920宽度,它隐藏了堆栈中的下一个面板。

我的XAML目前位于以下位置:

<ScrollViewer x:Name="scrVwrProductCategories" Style="{DynamicResource scrVwrFullWidthHorizontal}" PanningMode="HorizontalOnly" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled">
    <StackPanel Width="Auto" Height="750" HorizontalAlignment="Right" Orientation="Horizontal">
        <WrapPanel Style="{DynamicResource wrpPnlProductCategoriesPanels}" x:Name="wrpPnlProductCategories">
            <!-- Constant currently for count of buttons per WrapPanel = 6-->
            <!-- This is filled in dynamically at runtime
        <controls:btnLarge Height="325" Width="500" Margin="20,0" TitleText="My Item" NoteText="" ShowNote="Collapsed" ShowSubTitle="Collapsed"/>
            -->
        </WrapPanel>
        <WrapPanel Style="{DynamicResource wrpPnlProductCategoriesPanels}" x:Name="wrpPnlProductCategories2">
            <!-- Constant currently for count of buttons per WrapPanel = 6-->
            <!-- This is filled in dynamically at runtime
        <controls:btnLarge Height="325" Width="500" Margin="20,0" TitleText="My Item" NoteText="" ShowNote="Collapsed" ShowSubTitle="Collapsed"/>
            -->
        </WrapPanel>
    </StackPanel>
  <Kiosk:SwipeForMoreArrow x:Name="ctrlSwipeForMoreArrow" HorizontalAlignment="Right" VerticalAlignment="Center" Visibility="Collapsed"/>
</ScrollViewer>

1 个答案:

答案 0 :(得分:0)

您的目标是仅通过XAML实现这一目标吗?否则,您可以尝试通过OnScrolledChanged事件获取Scrollviewer的this.Horizo​​ntalOffset,以确定它是0还是最大。 也许这个链接也可能有帮助: How to find that ScrollViewer is scrolled to the end in WPF?