用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill maui-custom-handlers命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
基于 SOC 职业分类
正在显示 SKILL.md
| name | maui-custom-handlers |
| description | > Use when this capability is needed. |
| Scenario | Approach |
|---|---|
| Change how a built-in control looks/behaves on one platform | Customize — use AppendToMapping / PrependToMapping |
| Need the change on only some instances of a control | Customize — subclass the control + type-check in mapper |
| Need a completely new cross-platform control with native backing | Create new handler with partial classes |
⚠️ Prefer
AppendToMappingoverModifyMapping.ModifyMappingreplaces the default mapper action entirely — if the framework adds behaviour in a future release, your override silently drops it.
Every instance of the control is affected. Guard with a subclass check for instance-specific behaviour:
// ❌ Removes borders from EVERY Entry in the app
EntryHandler.Mapper.AppendToMapping("NoBorder", (handler, view) =>
{
#if ANDROID
handler.PlatformView.Background = null;
#endif
});
// ✅ Only affects BorderlessEntry instances
EntryHandler.Mapper.AppendToMapping("NoBorder", (handler, view) =>
{
if (view is not BorderlessEntry) return;
#if ANDROID
handler.PlatformView.Background = null;
#endif
});
HandlerChangingFailing to remove native event handlers causes memory leaks because the native view may outlive the managed wrapper.
// ❌ Subscribes but never unsubscribes — leaks
entry.HandlerChanged += (s, e) =>
{
#if ANDROID
((Entry)s!).Handler!.PlatformView.As<Android.Widget.EditText>()!
.FocusChange += OnNativeFocusChange;
#endif
};
// ✅ Pair subscribe in HandlerChanged with unsubscribe in HandlerChanging
entry.HandlerChanged += OnHandlerChanged;
entry.HandlerChanging += OnHandlerChanging;
Namespace and class name must match exactly across the shared handler file and every platform file. A mismatch silently creates separate classes — no compiler error, just a handler that does nothing on that platform.
using placementThe using PlatformView = ... aliases must be at the top of the shared
handler file (not the platform files) so the ViewHandler<TControl, TPlatformView>
base-class generic resolves correctly per platform.
// ✅ Top of Handlers/VideoPlayerHandler.cs
#if ANDROID
using PlatformView = Android.Widget.VideoView;
#elif IOS || MACCATALYST
using PlatformView = AVKit.AVPlayerViewController;
#elif WINDOWS
using PlatformView = Microsoft.UI.Xaml.Controls.MediaPlayerElement;
#endif
CreatePlatformView()Each platform partial must override CreatePlatformView(). Omitting it
produces a compile error — but the error message points at the base class,
not your handler, making it confusing to debug.
| Method | Risk | Use when |
|---|---|---|
AppendToMapping | Low — runs after default | Adding behaviour without breaking defaults |
PrependToMapping | Low — runs before default | Setting initial state that the default can override |
ModifyMapping | ⚠️ High — replaces default | You intentionally want to suppress the framework's mapper logic |
| Mapper | Purpose | Pattern |
|---|---|---|
PropertyMapper | Sync a bindable property to the native view | Runs whenever the property value changes |
CommandMapper | Fire-and-forget action from control → handler | Runs once per invocation, no return value |
⚠️ Don't put property sync logic in
CommandMapper— it won't re-run when the property changes, leading to stale native views.
View (or appropriate base)using PlatformView = ... aliasesViewHandler<TControl, PlatformView>PropertyMapper maps every bindable propertyCreatePlatformView()MauiProgram.cs via ConfigureMauiHandlersHandlerChangingConverted and distributed by TomeVault — claim your Tome and manage your conversions.