0

I have control MoreOption (use SkiaSharp draw ). I use it at ListView . Every row of ListView have 1 MoreOption . When i clicked, it show popup (Update, Delete) . I use TapGestureRecognizer_Tapped to get position at row has chosen , but I can't get it's position . Result : i want show popup at MoreOption's position when i clicked.

enter image description here

Here's code:

Inside ListView.xaml

<ViewCell>
     <AbsoluteLayout>
         <Label Text="{Binding ID , StringFormat='{0:D3}'}"  AbsoluteLayout.LayoutBounds="0,0.5,0.75,1"
                                    VerticalTextAlignment="Center" 
                                    FontAttributes="Bold" AbsoluteLayout.LayoutFlags="All"/>
         <Label Text="{Binding FullName}"                        
                                    VerticalTextAlignment="Center"  AbsoluteLayout.LayoutBounds="0.4,0.5,0.75,2" AbsoluteLayout.LayoutFlags="All"
                                    FontAttributes="Bold" FontSize="20"
                                    TextColor="{Binding Number, Converter={StaticResource ColorConverter}}"/>
         <AbsoluteLayout  AbsoluteLayout.LayoutBounds="1.84,0.5,0.5,0.5" AbsoluteLayout.LayoutFlags="All">
             <AbsoluteLayout.GestureRecognizers>
                  <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" NumberOfTapsRequired="1"></TapGestureRecognizer>
             </AbsoluteLayout.GestureRecognizers>
             <controls:MoreOption />
         </AbsoluteLayout>
   </AbsoluteLayout>
 </ViewCell>

Inside MoreOption.xaml :

<AbsoluteLayout VerticalOptions="FillAndExpand">
        <skia:SKCanvasView x:Name="canvasView" AbsoluteLayout.LayoutBounds="0,0,0.075,0.1"
                        PaintSurface="OnCanvasViewPaintSurface"
                        AbsoluteLayout.LayoutFlags="All"/>

        <skia:SKCanvasView x:Name="canvasView1" AbsoluteLayout.LayoutBounds="0,0.045,0.075,0.1"
                        PaintSurface="OnCanvasViewPaintSurface"
                        AbsoluteLayout.LayoutFlags="All" />

        <skia:SKCanvasView x:Name="canvasView2" AbsoluteLayout.LayoutBounds="0,0.09,0.075,0.1"
                        PaintSurface="OnCanvasViewPaintSurface"
                        AbsoluteLayout.LayoutFlags="All" />
    </AbsoluteLayout>

Inside ListUser.xaml.cs :

 private void TapGestureRecognizer_Tapped(object sender,TappedEventArgs e,Point p)
 {
        ContentPage Page = Application.Current.MainPage.Navigation.NavigationStack.LastOrDefault() as ContentPage;
        var popuppage = new MenuMoreOptions(); popuppage.Layout(new Rectangle(p, new Size(50, 100)));
        Page.Content.Navigation.PushPopupAsync(popuppage);
 }

Inside MenuMoreOptions.xaml :

<AbsoluteLayout x:Name="MenuOptions" IsEnabled="{Binding Editable}" Margin="100,200"
             BackgroundColor="Aqua">
    <StackLayout Orientation="Vertical">
        <Button BackgroundColor="Transparent" Text="Update"/>
        <Button BackgroundColor="Transparent" Text="Delete"/>
    </StackLayout>
</AbsoluteLayout>

Have any way resolve this issue ???

  • You can refer to:https://stackoverflow.com/questions/43186122/xamarin-how-to-get-cursor-touch-coordinates-position-x-and-y. – nevermore Nov 12 '18 at 09:07
  • Thanks. I have read MR.Getsure but it licensed . I research about Custom Renderer on every platform, But i can't find custom renderer of TapGestureRecognizer . Do you have any Ebook about Custom renderer of TapGestureRecognizer ? i want use control myseft without licensed . Thanks so much – Tân Võ Hoàng Nov 13 '18 at 08:06

0 Answers0