滚动不';t停止,同时通过在UWP中的投掷动作后点击屏幕来停止滚动动作

滚动不';t停止,同时通过在UWP中的投掷动作后点击屏幕来停止滚动动作,uwp,Uwp,我尝试了下面的方法,同时将父StackPanel(VisualContainer)和子StackPanel(Items)上的操纵模式作为操纵模式进行处理。但我面临的问题是滚动没有停止,而停止滚动动作后触摸屏幕。我使用下面的代码 问题:在UWP中执行投掷动作后,触摸屏幕时滚动未停止 对于子StackPanel(Items)操作模式,它可以作为系统正常工作。但不在子StackPanel(Items)操作模式下工作 注意:我必须使用子堆栈面板(项目)操作模式作为所有模式。 这里我附上了示例代码片段 M

我尝试了下面的方法,同时将父StackPanel(VisualContainer)和子StackPanel(Items)上的操纵模式作为操纵模式进行处理。但我面临的问题是滚动没有停止,而停止滚动动作后触摸屏幕。我使用下面的代码

问题:在UWP中执行投掷动作后,触摸屏幕时滚动未停止

对于子StackPanel(Items)操作模式,它可以作为系统正常工作。但不在子StackPanel(Items)操作模式下工作

注意:我必须使用子堆栈面板(项目)操作模式作为所有模式。

这里我附上了示例代码片段

MainPage.xaml

<Page
    x:Class="App4.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App4"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>

        <ScrollViewer x:Name="ScrollViewer">

            <!--It is a Parent Stack Panel - VisualContainer-->

            <StackPanel Background="AntiqueWhite" x:Name="VisualContainer" HorizontalAlignment="Stretch">

                <!--It is a Child Stack Panel, The below views are Items-->

                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />
                <local:StackPanelExt Background="Aquamarine" Height="100" />
                <local:StackPanelExt Background="Pink" Height="100" />

            </StackPanel>

        </ScrollViewer>

    </Grid>

</Page>

MainPage.xaml.cs

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace App4
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();

            VisualContainer.ManipulationMode = ManipulationModes.All;
            VisualContainer.ManipulationDelta += VisualContainer_ManipulationDelta;

        }

        private void VisualContainer_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
        {
            ScrollViewer.ChangeView(0, ScrollViewer.VerticalOffset - e.Delta.Translation.Y, null, true);
        }

    }

    public class StackPanelExt : StackPanel
    {
        public StackPanelExt()
        {
            //this.ManipulationDelta += StackPanelExtExt_ManipulationDelta;
            this.ManipulationMode = ManipulationModes.All;
        }

        private void StackPanelExtExt_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
        {
            var x = e.Cumulative.Translation.X;
            var y = e.Cumulative.Translation.Y;

            if (Math.Abs(y) <= Math.Abs(x))
            {
                e.Handled = true;
            }
            else
            {
                e.Handled = false;
            }

        }
    }
}
使用系统;
使用System.Collections.Generic;
使用系统诊断;
使用System.IO;
使用System.Linq;
使用System.Runtime.InteropServices.WindowsRuntime;
使用Windows基金会;
使用Windows。
使用Windows.UI;
使用Windows.UI.Xaml;
使用Windows.UI.Xaml.Controls;
使用Windows.UI.Xaml.Controls.Primitives;
使用Windows.UI.Xaml.Data;
使用Windows.UI.Xaml.Input;
使用Windows.UI.Xaml.Media;
使用Windows.UI.Xaml.Navigation;
//空白页项模板被记录在https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
名称空间App4
{
/// 
///可以单独使用或在框架内导航到的空页。
/// 
公共密封部分类主页面:第页
{
公共主页()
{
this.InitializeComponent();
VisualContainer.操纵模式=操纵模式.All;
VisualContainer.OperationDelta+=VisualContainer_OperationDelta;
}
私有void VisualContainer_操纵delta(对象发送方,操纵deltaroutedventargs e)
{
ScrollViewer.ChangeView(0,ScrollViewer.VerticalOffset-e.Delta.Translation.Y,null,true);
}
}
公共类StackPanelExt:StackPanel
{
公共StackPanelExt()
{
//this.manufactionDelta+=StackPanelExtExt\u manufactionDelta;
this.manufactionmode=manufactionmodes.All;
}
私有void StackPanelExtExt_操纵delta(对象发送方,操纵deltaroutedventargs e)
{
var x=e.累计换算率.x;
var y=e.累计换算率.y;

如果(Math.Abs(y),启动fling后按下poniter后,可以通过处理VisualContainer的操纵增量事件来停止滚动,如下所示

bool isPointerPressed = false;
    private void VisualContainer_PointerPressed(object sender, PointerRoutedEventArgs e)
    {
        isPointerPressed = true;
        Debug.WriteLine("PointerPressed: " + ScrollViewer.VerticalOffset);
    }

    private void VisualContainer_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
    {
        if(!e.IsInertial)
        {
            isPointerPressed = false;
        }
        else if(isPointerPressed)
        {
            e.Complete();
            return;
        }
        var offset = ScrollViewer.VerticalOffset - e.Delta.Translation.Y;
        ScrollViewer.ChangeView(0, offset, null, true);
    }

我已经处理了基于isPointerPressed变量的操作。还通过检查操作事件参数的ISenetial来确定指针在触发后被按下。

启动触发后按下poniter后,可以通过处理VisualContainer的操纵增量事件来停止滚动,如下所示

bool isPointerPressed = false;
    private void VisualContainer_PointerPressed(object sender, PointerRoutedEventArgs e)
    {
        isPointerPressed = true;
        Debug.WriteLine("PointerPressed: " + ScrollViewer.VerticalOffset);
    }

    private void VisualContainer_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
    {
        if(!e.IsInertial)
        {
            isPointerPressed = false;
        }
        else if(isPointerPressed)
        {
            e.Complete();
            return;
        }
        var offset = ScrollViewer.VerticalOffset - e.Delta.Translation.Y;
        ScrollViewer.ChangeView(0, offset, null, true);
    }

我已经处理了基于isPointerPressed变量的操作。还通过检查操作事件参数的ISenetial来确定抛出后按下的指针。

非常棒的答案……非常感谢……兄弟……工作正常……非常棒的答案……非常感谢……兄弟……工作正常。。。