If i tap on GraphicsView
should event and call method tap
, but debugger does not respond on tap. Label do not change too.
XAML:
<Label
x:Name="lb"
Text="You touch nothing"/>
<GraphicsView
x:Name="tralala"
StartInteraction="tap"/>
CS:
private void tap(object sender, TouchEventArgs e)
{
lb.Text = "You touch my tralala"
}
I try add GestureRecognizers :
<GraphicsView
x:Name="previewer"
StartInteraction="tap">
<GraphicsView.GestureRecognizers >
<TapGestureRecognizer Tapped="tapp"/>
</GraphicsView.GestureRecognizers>
</GraphicsView>
CS:
private void tapp(object sender, TappedEventArgs e)
{
lb.Text = "You touch my tralala"
}
but this not helping
Sanyok is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
4
If i tap on GraphicsView should event and call method tap, but debugger does not respond on tap
The GraphicsView‘s default HeightRequest
and WidthRequest
is -1 on android, so you need to set the value of them to make the GraphicsView can render on the screen.
You can get the distance by : var dis = firstpoint.Distance(secondpoint)
. Just check the source code: public double Distance.
And for more information about the api, you can check the official document about Microsoft.Maui.Graphics.Point
.
The GraphicsView as Liyung said, should have heightRequest//WidthRequest to ensure that the view is not obstructed by other controls (defauylt values are -1), so if you set those values, the tap will be recognized in graphicsView Zone:
<GraphicsView
x:Name="tralala"
HeightRequest="setvalue"
WidthRequest="setvalue"
StartInteraction="tap"/>
And to get the distance between 2 points you could use the following using the Point structure of library Microsoft.Maui.Graphics:
public double GetDistance(Point firstPosition, Point secondPosition)
{
double axisX = secondPosition.X - firstPosition.X;
double axisY = secondPosition.Y - firstPosition.Y;
return Math.Sqrt(axisX * axisX + axisY * axisY);
}