Peri Hartman
Peri Hartman

Reputation: 19484

UWP UserControl with Canvas: how do you draw?

For the Uno platform, based on UWP, I want to create a UserControl which contains a Canvas where I can draw something. I can't find any documentation or examples on what drawing events occur and how to use them.

I believe my XAML can be, minimally, like this:

<UserControl
  x:Class="UnoTest.Shared.Controls.ExpandableImage"
  ...
  <Canvas />
</UserControl>

And the code behind like this:

namespace UnoTest.Shared.Controls
{
  public sealed partial class ExpandableImage : UserControl
  {
    public ExpandableImage()
    {
      this.InitializeComponent();
    }
  }
}

And, surely, there must be some callbacks for drawing on the canvas.

Upvotes: 2

Views: 632

Answers (2)

Lukas
Lukas

Reputation: 1

Jerome Laban talked about how to use SkiaSharp on the Uno Platform in a twitch livestream yesterday. Maybe that's interesting for you: https://www.twitch.tv/videos/880058411?t=0h36m27s

I don't know how long the video will stay on twitch, but I think they'll upload the stream to youtube in the next days. Here is the link to the youtube playlist regarding the twitch streams: https://www.youtube.com/playlist?list=PLl_OlDcUya9pRqt9A0vpyi89Vl-uq3nSb

Hopefully the video will appear there in some days.

Upvotes: 0

Michael S. Scherotter
Michael S. Scherotter

Reputation: 10785

I would suggest using Win2D CanvasControl if you want to draw arbitrary graphics in a UserControl.

SkiaSharp Uno Platform is also an option if you want to target the Uno Platform.

Upvotes: 1

Related Questions