This repository was archived by the owner on Dec 21, 2023. It is now read-only.
Replies: 1 comment
-
Hi @kestlerio
using Microsoft.Maui.Graphics;
namespace MyMauiApp
{
public class GraphicsDrawable : IDrawable
{
public void Draw(ICanvas canvas, RectangleF dirtyRect)
{
// Drawing code goes here
canvas.StrokeColor = Colors.Red;
canvas.StrokeSize = 6;
canvas.DrawLine(10, 50, 90, 100);
}
}
}
<ContentPage xmlns=http://schemas.microsoft.com/dotnet/2021/maui
xmlns:x=http://schemas.microsoft.com/winfx/2009/xaml
xmlns:drawable="clr-namespace:MyMauiApp"
x:Class="MyMauiApp.MainPage">
<ContentPage.Resources>
<drawable:GraphicsDrawable x:Key="drawable" />
</ContentPage.Resources>
<StackLayout>
<GraphicsView Drawable="{StaticResource drawable}"
HeightRequest="500"
WidthRequest="500" />
</StackLayout>
</ContentPage> Hope this helps. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
Cool project!
This may be a silly question, but I just don't get it:
There are plenty examples for WinForms, UWP, WPF, iOS, Android etc.
But how do I get the Maui.Graphics functionality inside a MAUI app? (specifically MAUI Preview 5)
Thanks in advance :-)
Edit: Can it be that one has to just use a SkiaSharp view (SKCanvasView) inside the common Xaml? But SkiaSharp is not ready for MAUI (yet), is it?
Beta Was this translation helpful? Give feedback.
All reactions