maui-accessibility
Guide for making .NET MAUI apps accessible — screen reader support via SemanticProperties, heading levels, AutomationProperties…
Guidance for custom drawing with Microsoft.Maui.Graphics, GraphicsView, canvas drawing operations, shapes, paths, text rendering, image drawing, shadows, clipping, and canvas state management. USE FOR: "custom drawing", "GraphicsView", "canvas drawing", "draw shapes", "draw
$ npx -y skills add davidortinau/maui-skills --skill maui-graphics-drawing --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/maui-graphics-drawingContext preview
The summary Claude sees to decide when to auto-load this skill.
Guidance for custom drawing with Microsoft.Maui.Graphics, GraphicsView, canvas drawing operations, shapes, paths, text rendering, image drawing, shadows, clipping, and canvas state management. USE FOR: "custom drawing", "GraphicsView", "canvas drawing", "draw shapes", "draw
name: maui-graphics-drawing description: > Guidance for custom drawing with Microsoft.Maui.Graphics, GraphicsView, canvas drawing operations, shapes, paths, text rendering, image drawing, shadows, clipping, and canvas state management. USE FOR: "custom drawing", "GraphicsView", "canvas drawing", "draw shapes", "draw path", "draw text", "ICanvas", "IDrawable", "shadows", "clipping", "Microsoft.Maui.Graphics". DO NOT USE FOR: view animations (use maui-animations), gesture handling on drawn elements (use maui-gestures), or app icons (use maui-app-icons-splash).
| Issue | Fix | |---|---| | Nothing draws on screen | Ensure `Drawable` is set on `GraphicsView` and the control has non-zero `HeightRequest`/`WidthRequest` | | State bleeds between shapes | Wrap isolated sections in `SaveState()` / `RestoreState()` pairs | | Shadows stick to later draws | Call `canvas.SetShadow(SizeF.Zero, 0, null)` after drawing the shadowed element | | Clipping never resets | Clipping is cumulative per frame — use `SaveState`/`RestoreState` around clip regions | | UI freezes during drawing | Never do I/O, network, or heavy computation inside `Draw()` — it runs on the UI thread |
⚠️ Unpaired `SaveState`/`RestoreState` causes state leaks across draw calls.
// ✅ Correct — isolated state canvas.SaveState(); canvas.StrokeColor = Colors.Red; canvas.StrokeSize = 6; canvas.DrawRectangle(10, 10, 80, 80); canvas.RestoreState(); // Stroke reverts to previous values // ❌ Wrong — state leaks to everything drawn after canvas.StrokeColor = Colors.Red; canvas.StrokeSize = 6; canvas.DrawRectangle(10, 10, 80, 80); // Every subsequent shape is now red with size 6
Saves/restores: stroke, fill, font, shadow, clip, and transforms. Nest calls for layered isolation.
// ✅ Correct — queue a redraw graphicsView.Invalidate(); // ❌ Wrong — never call Draw() directly myDrawable.Draw(canvas, rect);
// ✅ Pre-computed path (field)
private readonly PathF _starPath = BuildStarPath();
public void Draw(ICanvas canvas, RectF dirtyRect)
{
canvas.FillPath(_starPath);
}
// ❌ Allocating every frame
public void Draw(ICanvas canvas, RectF dirtyRect)
{
var path = new PathF();
// ...build path every frame...
canvas.FillPath(path);
}Shadows apply to **all subsequent draws** until explicitly removed. Clips accumulate and can only be undone with `RestoreState()`:
// ✅ Shadow: remove after use canvas.SetShadow(new SizeF(5, 5), 4, Colors.Gray); canvas.FillRectangle(20, 20, 100, 60); canvas.SetShadow(SizeF.Zero, 0, null); // ← must remove // ✅ Clip: isolate with SaveState/RestoreState canvas.SaveState(); canvas.ClipRectangle(20, 20, 100, 100); canvas.FillRectangle(0, 0, 200, 200); // clipped canvas.RestoreState(); // clip removed // ❌ Clip persists — everything after is also clipped canvas.ClipRectangle(20, 20, 100, 100); canvas.FillEllipse(150, 150, 50, 50); // unintentionally clipped!
// ✅ Properties then draw canvas.StrokeColor = Colors.Blue; canvas.DrawRectangle(10, 10, 100, 50); // ❌ Setting after draw has no effect on previous shape canvas.DrawRectangle(10, 10, 100, 50); canvas.StrokeColor = Colors.Blue;
| Need | Approach | |---|---| | Simple shapes / static graphics | Single `IDrawable`, draw in `Draw()` | | Animated graphics | Update state externally, call `Invalidate()` from timer/animation | | Complex layered scene | Multiple `SaveState`/`RestoreState` blocks, or separate drawables | | Hit testing on drawn elements | Track shape bounds manually — `GraphicsView` has no built-in hit test on drawn content | | Platform-specific rendering | Use handlers/platform code; `Microsoft.Maui.Graphics` is cross-platform only |
A collection of 41 skills for .NET MAUI development, UI/UX design reasoning, and Xamarin migration, designed for use with GitHub Copilot CLI and Claude Code.
Guide for making .NET MAUI apps accessible — screen reader support via SemanticProperties, heading levels, AutomationProperties…
.NET MAUI view animations, custom animations, easing functions, rotation, scale, translation, and fade effects. USE FOR: "animate…
.NET MAUI app icon configuration, splash screen setup, SVG to PNG conversion at build time, composed/adaptive icons, and…
.NET MAUI app lifecycle guidance covering the four app states (not running, running, deactivated, stopped), cross-platform Window…
Guide for .NET MAUI apps consuming .NET Aspire-hosted backend services. Covers AppHost configuration, service discovery for…
Add authentication to .NET MAUI apps. Covers WebAuthenticator for generic OAuth 2.0 / social login, and MSAL.NET for Microsoft…