Manage annotation events in your MAUI app
In addition to controlling annotation changes via our create, update, and delete APIs, we also expose a number of events that can be used to intercept annotation changes that originate in the user interface (UI) by clicks from the user.
Event | Use case |
---|---|
IAnnotation.Focused | Fires when an annotation is focused. |
IAnnotation.Unfocused | Fires when an annotation loses focus. |
IAnnotation.Pressed | Fires when an annotation is pressed. |
IAnnotation.Selected | Fires when an annotation is selected. |
IAnnotation.Deselected | Fires when an annotation is deselected. |
IAnnotationManager.AnnotationsChanged | Fires when annotations change either due to user action or via the API. |
IAnnotationManager.AnnotationsChanging | Fires when a user starts or ends an interaction with an annotation. |
IAnnotationManager.AnnotationsCreated | Fires when a new annotation is created. |
IAnnotationManager.AnnotationsDeleted | Fires when annotations were deleted. |
IAnnotationManager.AnnotationsLoaded | Fires when annotations are loaded from annotation provider. |
IAnnotationManager.AnnotationsSaving | Fires before annotations will be saved. |
IAnnotationManager.AnnotationsSaved | Fires before annotations were saved. |
IAnnotationManager.AnnotationsUpdated | Fires when annotations were updated. |
annotation.Focused += () => { Console.WriteLine("Annotation focused");};
annotation.Unfocused += () => { Console.WriteLine("Annotation unfocused");};
annotation.Pressed += (isSelected, preventDefault) => { Console.WriteLine("Annotation pressed");};
annotation.Selected += () => { Console.WriteLine("Annotation selected");};
annotation.Deselected += () => { Console.WriteLine("Annotation deselected");};
annotationManager.AnnotationsChanged += () => { Console.WriteLine("Annotations changed");};
annotationManager.AnnotationsChanging += (annotations, reason) => { if (reason.AnnotationsChaningReason.DrawEnd) { Console.WriteLine("Annotations changing"); }};
annotationManager.AnnotationsCreated += (annotations) => { foreach(var annotation in annotations) { Console.WriteLine(annotation.id); }};
annotationManager.AnnotationsDeleted += (annotations) => { foreach(var annotation in annotations) { Console.WriteLine(annotation.id); }};
annotationManager.AnnotationsLoaded += (annotations) => { foreach(var annotation in annotations) { Console.WriteLine(annotation.id); }};
annotationManager.AnnotationsSaving += () => { Console.WriteLine("Saving annotations");};
annotationManager.AnnotationsSaved += () => { Console.WriteLine("Saved annotations");};
annotationManager.AnnotationsUpdated += (annotations) => { foreach(var annotation in annotations) { Console.WriteLine(annotation.id); }};