在 ScrollViewer 内旋转,scrollviewer 不会滚动 [英] Pivot inside a ScrollViewer, scrollviewer wont scroll

查看:72
本文介绍了在 ScrollViewer 内旋转,scrollviewer 不会滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,其中包含许多 UI 元素,并且其垂直可滚动,如时间轴.在中间我有一个枢轴,当它获得焦点或鼠标指针进入滚动查看器时停止滚动.

I have a page that has many UI elements and its scrollable vertical like a Timeline. In the middle I have a pivot that when its gets focus or the mouse pointer enters the scrollviewer stop scrolling.

<ScrollViewer x:Name="scrollViewer" VerticalScrollMode="Enabled" HorizontalScrollMode="Disabled">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid.RowDefinitions>
        <RowDefinition Height="90"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition MaxWidth="180"/>
        <ColumnDefinition Width="360*" MaxWidth="1060"/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>
      <!-- more UI elements-->
    <Pivot ScrollViewer.HorizontalScrollMode="Disabled" ScrollViewer.VerticalScrollMode="Disabled" x:Name="InfoPivot" Title="Pivot" Grid.Column="1"  Grid.Row="4" VerticalAlignment="Top" MaxWidth="1060" HorizontalAlignment="Left" MinHeight="500">
        <PivotItem Header="Mylist">
            <GridView x:Name="theList" Margin="20,10,10,13" ItemTemplate="{StaticResource GridViewTemplate1}" VerticalAlignment="Top" HorizontalAlignment="Center"/>
        </PivotItem>
    </Pivot>
</Grid>

推荐答案

我找到了一个解决方案,但我希望有更好的方法.

I found a solution but I hope there is a better way.

编辑:更改了分区,使其更像默认滚动条.

Edit: Changed the division it makes it feel more like the the default scroll.

private void PivotItem_PointerWheelChanged(object sender, PointerRoutedEventArgs e)
{
    if (e.GetCurrentPoint(scrollViewer).Properties.MouseWheelDelta == (-120))
    {
        // On Mouse Wheel scroll Backward
        scrollViewer.ChangeView(null, scrollViewer.VerticalOffset + Window.Current.CoreWindow.Bounds.Height / 7, null, false);
    }
    if (e.GetCurrentPoint(scrollViewer).Properties.MouseWheelDelta == (120))
    {
        // On Mouse Wheel scroll Forward
        scrollViewer.ChangeView(null,scrollViewer.VerticalOffset - Window.Current.CoreWindow.Bounds.Height / 7, null, false);
    }
}

这篇关于在 ScrollViewer 内旋转,scrollviewer 不会滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆