Hello,
Welcome to our Microsoft Q&A platform!
Do you want to achieve the result like following GIF?
If so, you can install TouchTracking.Forms
nuget packages. add Effect for the SKCanvasView
<AbsoluteLayout x:Name="myabs">
<views:SKCanvasView
AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="SizeProportional"
x:Name="canvasView" >
<views:SKCanvasView.Effects>
<tt:TouchEffect Capture="True" TouchAction="TouchEffect_TouchAction" />
</views:SKCanvasView.Effects>
</views:SKCanvasView>
</AbsoluteLayout>
Here is layout backgroud code
private void TouchEffect_TouchAction(object sender, TouchTracking.TouchActionEventArgs args)
{
var x = args.Location.X;
var y = args.Location.Y;
var v = new View1();
AbsoluteLayout.SetLayoutBounds(v, new Rectangle(x, y, 0.25, 0.25));
AbsoluteLayout.SetLayoutFlags(v, AbsoluteLayoutFlags.SizeProportional);
myabs.Children.Add(v);
}
when we click the screen, we get the X/Y point, then Add our custom control.
I make an custom control.
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="SkiaSharpDemo.View1">
<ContentView.Content>
<StackLayout>
<ImageButton WidthRequest="50" HeightRequest="50" BackgroundColor="Transparent" Source="hamburger.png" Clicked="ImageButton_Clicked" ></ImageButton>
<Frame IsVisible="false" x:Name="myframe" WidthRequest="100" HeightRequest="70">
<StackLayout>
<Label FontSize="Small" Text="Edit"/>
<Label FontSize="Small" Text="Duplicate"/>
<Label FontSize="Small" Text="Remove"/>
</StackLayout>
</Frame>
</StackLayout>
</ContentView.Content>
</ContentView>
//background code
public partial class View1 : ContentView
{
public View1()
{
InitializeComponent();
}
private void ImageButton_Clicked(object sender, EventArgs e)
{
myframe.IsVisible = !myframe.IsVisible;
}
}
I do not judge the border of the views:SKCanvasView, you can judge it by yourself.
Best Regards,
Leon Lu
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.