You need to enable JavaScript to run this app.
最新活动
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

PanGesture在UWP Xamarin Forms中只调用一次Pangesture更新事件。这就是为什么拖动不起作用。

在UWP Xamarin Forms中,如果PanGesture只调用一次,并且拖动不起作用,可能是因为没有正确处理PanGesture的更新事件。下面是一个示例代码,展示如何在UWP Xamarin Forms中正确处理PanGesture的更新事件:

using Xamarin.Forms;
using Xamarin.Forms.Platform.UWP;

[assembly: ExportRenderer(typeof(View), typeof(CustomRenderer))]

namespace YourNamespace
{
    public class CustomRenderer : ViewRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<View> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                // 添加PanGesture的处理
                Control.ManipulationMode = Windows.UI.Xaml.Input.ManipulationModes.All;
                Control.ManipulationDelta += Control_ManipulationDelta;
                Control.ManipulationCompleted += Control_ManipulationCompleted;
            }
        }

        private void Control_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        {
            // 处理PanGesture的更新事件
            if (Element is View view)
            {
                var panGesture = view.GestureRecognizers.FirstOrDefault(g => g is PanGestureRecognizer) as PanGestureRecognizer;
                if (panGesture != null && panGesture.PanUpdatedCommand != null && panGesture.PanUpdatedCommand.CanExecute(null))
                {
                    var panEventArgs = new PanUpdatedEventArgs(GestureStatus.Running, e.Cumulative.Translation.X, e.Cumulative.Translation.Y);
                    panGesture.PanUpdatedCommand.Execute(panEventArgs);
                }
            }
        }

        private void Control_ManipulationCompleted(object sender, Windows.UI.Xaml.Input.ManipulationCompletedRoutedEventArgs e)
        {
            // 处理PanGesture的完成事件
            if (Element is View view)
            {
                var panGesture = view.GestureRecognizers.FirstOrDefault(g => g is PanGestureRecognizer) as PanGestureRecognizer;
                if (panGesture != null && panGesture.PanUpdatedCommand != null && panGesture.PanUpdatedCommand.CanExecute(null))
                {
                    var panEventArgs = new PanUpdatedEventArgs(GestureStatus.Completed);
                    panGesture.PanUpdatedCommand.Execute(panEventArgs);
                }
            }
        }
    }
}

在上面的示例代码中,我们创建了一个自定义渲染器(CustomRenderer),并在OnElementChanged方法中添加了PanGesture的处理。我们通过ManipulationMode属性将控件的ManipulationMode设置为All,以便可以处理拖动手势。然后,我们订阅了Control的ManipulationDelta事件和ManipulationCompleted事件,并在事件处理程序中触发PanGesture的更新事件。

请注意,上面的示例代码假设您已经在Xamarin Forms中添加了一个PanGestureRecognizer,并将其与相应的PanUpdatedCommand绑定。

本文内容通过AI工具匹配关键字智能整合而成,仅供参考,火山引擎不对内容的真实、准确或完整作任何形式的承诺。如有任何问题或意见,您可以通过联系service@volcengine.com进行反馈,火山引擎收到您的反馈后将及时答复和处理。
展开更多
面向开发者的云福利中心,ECS 60元/年,域名1元起,助力开发者快速在云上构建可靠应用

社区干货

特惠活动

热门爆款云服务器

100%性能独享,更高内存性能更佳,学习测试、web前端、企业应用首选,每日花费低至0.55元
60.00/1212.00/年
立即购买

域名注册服务

cn/top/com等热门域名,首年低至1元,邮箱建站必选
1.00/首年起32.00/首年起
立即购买

DCDN国内流量包100G

同时抵扣CDN与DCDN两种流量消耗,加速分发更实惠
2.00/20.00/年
立即购买

PanGesture在UWP Xamarin Forms中只调用一次Pangesture更新事件。这就是为什么拖动不起作用。-优选内容

doc_chunking
with the longest docu- ment spanning up to 85 pages. We compare the impact of pure text and text-image multi-modal pretraining encoders on the results. Our experiments demonstrate that, in DocTree dataset, our approach outperforms existing methods by an improvement of 12% in accuracy.\", \"positions\": {\"page_no\": [0], \"bbox\": [[63.962997, 233.97977, 282.53696, 407.78415]]}}", ...
doc_chunking
with the longest docu- ment spanning up to 85 pages. We compare the impact of pure text and text-image multi-modal pretraining encoders on the results. Our experiments demonstrate that, in DocTree dataset, our approach outperforms existing methods by an improvement of 12% in accuracy.\", \"positions\": {\"page_no\": [0], \"bbox\": [[63.962997, 233.97977, 282.53696, 407.78415]]}}", ...

PanGesture在UWP Xamarin Forms中只调用一次Pangesture更新事件。这就是为什么拖动不起作用。-相关内容

特惠活动

热门爆款云服务器

100%性能独享,更高内存性能更佳,学习测试、web前端、企业应用首选,每日花费低至0.55元
60.00/1212.00/年
立即购买

域名注册服务

cn/top/com等热门域名,首年低至1元,邮箱建站必选
1.00/首年起32.00/首年起
立即购买

DCDN国内流量包100G

同时抵扣CDN与DCDN两种流量消耗,加速分发更实惠
2.00/20.00/年
立即购买

产品体验

体验中心

云服务器特惠

云服务器
云服务器ECS新人特惠
立即抢购

白皮书

一图详解大模型
浓缩大模型架构,厘清生产和应用链路关系
立即获取

最新活动

爆款1核2G共享型服务器

首年60元,每月仅需5元,限量秒杀
立即抢购

火山引擎增长体验专区

丰富能力激励企业快速增长
查看详情

数据智能VeDI

易用的高性能大数据产品家族
了解详情

一键开启云上增长新空间

立即咨询