dotnet / dotnet/maui

Interactive objects on Canvas as in WPF

Open
#8,235 2 comments 0 reactions 0 assignees View on GitHub
area-drawing proposal/open t/enhancement ☀️
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 15h
Merged PRs (30d)
290

Description

### Description

As far as I know, MAUI canvas can only draw but the elements are not interactive or they do not exist as UI objects. Something like that has been possible in WPF for 10+ years.

https://stackoverflow.com/questions/7556493/how-do-i-recognize-a-mouse-click-on-a-line

```
private void myCanvas_Loaded(object sender, RoutedEventArgs e)
{
Line line = new Line();
//line is a real UI object with event handlers
line.MouseDown += new MouseButtonEventHandler(line_MouseDown);
line.MouseUp += new MouseButtonEventHandler(line_MouseUp);

line.Stroke = Brushes.Black;
line.StrokeThickness = 2;
line.X1 = 30; line.X2 = 80;
line.Y1 = 30; line.Y2 = 30;

myCanvas.Children.Add(line);
}

//when tap on ends, turn black
void line_MouseUp(object sender, MouseButtonEventArgs e)
{
// Change line colour back to normal
((Line)sender).Stroke = Brushes.Black;
}

//when tapped on, become red
void line_MouseDown(object sender, MouseButtonEventArgs e)
{
// Change line Colour to something
((Line)sender).Stroke = Brushes.Red;
}

```

These objects can be composed etc.
When will it come to MAUI?
Thank you

### Public API Changes

Shapes on canvas are UI elements with events, not just rendered pixels

### Intended Use-Case

Interactive complicated shapes where computing click coordinates (or handling different events!) is very complicated. (all other than rectangle, point, line and circle)
Example use case: interactive graphical shapes over image background. For example a situation on construction site which shows localities with problems and various items are displayed over the situation image and also miniatures of images are displayed and interactive points are localized into the image. Also the whole canvas shall be zoomable - zoom into any place and interact with objects in that part of the situation image.

Contributor guide

Open the contributing guide

Research direction

The issue names no repository files or tests. Start by reviewing MAUI Canvas APIs and platform behavior, then compare the requested WPF-style UI elements and events with current capabilities. Done would require an agreed public API and documented cross-platform behavior for interactive, composable shapes.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
frontend, mobile-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.