SKCanvasView Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A .NET MAUI view that can be used to draw 2D graphics using SkiaSharp with software (CPU) rendering.
public class SKCanvasView : Microsoft.Maui.Controls.View, SkiaSharp.Views.Maui.Controls.ISKCanvasViewController, SkiaSharp.Views.Maui.ISKCanvasView
public class SKCanvasView : Microsoft.Maui.Controls.View, SkiaSharp.Views.Maui.ISKCanvasView
- Inheritance
-
SKCanvasView
- Implements
Remarks
The SKCanvasView provides a software-rendered drawing surface for SkiaSharp graphics in .NET MAUI applications. For GPU-accelerated rendering, consider using SKGLView instead.
Subscribe to the PaintSurface event to draw custom graphics using the SKCanvas provided in the event arguments.
To request a redraw, call InvalidateSurface(). The view also supports touch events when EnableTouchEvents is set to true.
The underlying platform views are:
- Android:
SKCanvasView(Android) - iOS/Mac Catalyst/tvOS:
SKCanvasView(iOS) - Windows:
SKXamlCanvas
Constructors
| Name | Description |
|---|---|
| SKCanvasView() |
Initializes a new instance of the SKCanvasView class. |
Fields
| Name | Description |
|---|---|
| EnableTouchEventsProperty |
Identifies the EnableTouchEvents bindable property. |
| IgnorePixelScalingProperty |
Identifies the IgnorePixelScaling bindable property. |
Properties
| Name | Description |
|---|---|
| CanvasSize |
Gets the current size of the canvas in pixels. |
| EnableTouchEvents |
Gets or sets a value indicating whether touch events are enabled for this view. |
| IgnorePixelScaling |
Gets or sets a value indicating whether the canvas should ignore the device's pixel density scaling. |
Methods
| Name | Description |
|---|---|
| InvalidateSurface() |
Invalidates the surface and requests a redraw. |
| OnMeasure(Double, Double) |
Called when the view is measured. |
| OnPaintSurface(SKPaintSurfaceEventArgs) |
Called when the surface needs to be painted. |
| OnTouch(SKTouchEventArgs) |
Called when a touch event occurs on the view. |
Events
| Name | Description |
|---|---|
| PaintSurface |
Occurs when the surface needs to be painted. |
| Touch |
Occurs when a touch event is detected on the view. |
Explicit Interface Implementations
| Name | Description |
|---|---|
| ISKCanvasView.OnCanvasSizeChanged(SKSizeI) |
This member is used internally by the handler and should not be called directly. |
| ISKCanvasView.OnPaintSurface(SKPaintSurfaceEventArgs) |
This member is used internally by the handler and should not be called directly. |
| ISKCanvasView.OnTouch(SKTouchEventArgs) |
This member is used internally by the handler and should not be called directly. |
| ISKCanvasViewController.GetCanvasSize |
This member is used internally by the handler and should not be called directly. |
| ISKCanvasViewController.OnPaintSurface(SKPaintSurfaceEventArgs) |
This member is used internally by the handler and should not be called directly. |
| ISKCanvasViewController.OnTouch(SKTouchEventArgs) |
This member is used internally by the handler and should not be called directly. |
| ISKCanvasViewController.SurfaceInvalidated |
This member is used internally by the handler and should not be called directly. |