maui-gestures
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "maui-gestures":https://skillpi.com/zh/skills/deepskill-27ec14c114467c32ec27d310bc1f03b31cf6cac82218d41177f6673895df88c9。安装前核对上游来源和版本:https://github.com/davidortinau/maui-skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
在 .NET MAUI 应用中实现手势识别的指南,覆盖点击(tap)、滑动(swipe)、平移(pan)、捏合(pinch)、拖放(drag-and-drop)和指针手势的使用,包含 XAML 与 C# 示例、手势组合与平台差异说明。适用于点击手势、滑动手势、平移手势、捏合手势、拖放操作、指针手势、手势识别器及相关识别器(Tap/Swipe/PanGestureRecognizer)等场景。非由手势触发的动画、CollectionView 滑动操作或自定义绘图交互。
介绍来源: third_party · davidortinau · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: maui-gestures
description: >
Guidance for implementing tap, swipe, pan, pinch, drag-and-drop, and pointer
gesture recognizers in .NET MAUI applications. Covers XAML and C# usage,
combining gestures, and platform differences.
USE FOR: "tap gesture", "swipe gesture", "pan gesture", "pinch gesture",
"drag and drop", "pointer gesture", "gesture recognizer", "TapGestureRecognizer",
"SwipeGestureRecognizer", "PanGestureRecognizer", "combine gestures".
DO NOT USE FOR: animations triggered by gestures (use maui-animations),
CollectionView swipe actions (use maui-collectionview), or custom drawing interaction (use maui-graphics-drawing)..NET MAUI Gesture Recognizers
Deprecated API Warning
⚠️ In .NET 10,
ClickGestureRecognizeris deprecated. UseTapGestureRecognizer(touch/stylus) andPointerGestureRecognizer(mouse hover/press) instead.
Common Mistakes
One SwipeGestureRecognizer per direction
A single recognizer handles only one direction. Adding multiple directions to one recognizer silently fails on most platforms.
<!-- ❌ Only fires for Left — Right is ignored -->
<SwipeGestureRecognizer Direction="Left,Right" Swiped="OnSwiped" />
<!-- ✅ Separate recognizer per direction -->
<SwipeGestureRecognizer Direction="Left" Swiped="OnSwiped" />
<SwipeGestureRecognizer Direction="Right" Swiped="OnSwiped" />
AllowDrop defaults to false
Drop targets silently ignore drops if you forget this property.
<!-- ❌ Drop never fires — AllowDrop defaults to false -->
<StackLayout>
<StackLayout.GestureRecognizers>
<DropGestureRecognizer Drop="OnDrop" />
</StackLayout.GestureRecognizers>
</StackLayout>
<!-- ✅ Explicitly enable drops -->
<StackLayout>
<StackLayout.GestureRecognizers>
<DropGestureRecognizer AllowDrop="True" Drop="OnDrop" />
</StackLayout.GestureRecognizers>
</StackLayout>
Using TapGestureRecognizer for hover effects
Tap recognizers don't track pointer movement. Use PointerGestureRecognizer
for hover effects — it also enables the PointerOver visual state.
<!-- ❌ No hover tracking — user must tap to trigger -->
<Border>
<Border.GestureRecognizers>
<TapGestureRecognizer Command="{Binding HoverCommand}" />
</Border.GestureRecognizers>
</Border>
<!-- ✅ Proper hover detection + visual state -->
<Border>
<Border.GestureRecognizers>
<PointerGestureRecognizer PointerEnteredCommand="{Binding HoverInCommand}"
PointerExitedCommand="{Binding HoverOutCommand}" />
</Border.GestureRecognizers>
</Border>
Platform Differences That Bite
Pan delta coordinates differ by platform
| Platform | TotalX / TotalY relative to |
|---|---|
| iOS / Mac Catalyst | Start of gesture |
| Android | Previous event (not start!) |
| Windows | Start of gesture |
If sub-pixel accuracy matters, normalize Android deltas by accumulating them
manually rather than using TotalX/TotalY directly.
Pointer hover is mouse/trackpad only
On touch devices, PointerGestureRecognizer events fire on press/release
but hover is not tracked between touches. Don't rely on PointerMoved
for touch-based UI.
Cross-app drag-and-drop
| Platform | Supported |
|---|---|
| iPadOS / Mac Catalyst | ✅ Yes |
| Windows | ✅ Yes |
| Android | ❌ No |
Secondary button (right-click)
| Platform | Behaviour |
|---|---|
| iOS / Mac Catalyst | Buttons = ButtonsMask.Secondary works |
| Windows | Buttons = ButtonsMask.Secondary works |
| Android | Falls back to long-press — no true right-click |
Gesture Combination Conflicts
Combining pan + swipe on the same view conflicts on Android — the swipe may consume the gesture before pan starts. Test on all platforms, or use only one at a time.
Combining tap + pan works well — tap fires on quick taps, pan fires on sustained drags.
MVVM Best Practice
Prefer commands over events for testable view models. Both work identically at runtime, but commands are easier to mock and test.
<!-- ✅ Bindable command — testable -->
<TapGestureRecognizer Command="{Binding TapCommand}" />
<!-- ⚠️ Event handler — requires code-behind, harder to unit-test -->
<TapGestureRecognizer Tapped="OnTapped" />
Quick Rules
- One
SwipeGestureRecognizerper direction PointerGestureRecognizerfor hover, notTapGestureRecognizerAllowDrop="True"on drop targets — it defaults tofalse- Normalize pan deltas on Android (relative to previous event, not start)
- Prefer commands over events for MVVM
- Use
TapGestureRecognizerinstead of deprecatedClickGestureRecognizer(.NET 10) - Don't rely on
PointerMovedfor touch-based UI — hover doesn't track
当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 面向.NET MAUI开发者提供全面的手势识别器实现指南
- 涵盖多种常见手势(点击、滑动、平移、捏合、拖放、指针)
- 包含平台差异说明和最佳实践,具有广泛实用价值
亮点
- 触发词精准完整,覆盖多种变体
- 明确区分适用和不适用场景,边界清晰
亮点
- 结构清晰,包含常见错误、平台差异、最佳实践等章节
- 提供实用的代码示例和快速规则总结
- frontmatter完整,文档组织良好
亮点
- 提供了实用的代码示例和平台差异说明
- 指出了常见陷阱和最佳实践,提高执行可靠性
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。