我可以控制MoreOption(使用SkiaSharp draw)。我在ListView上使用它。 ListView的每一行都有1个MoreOption。当我单击时,它显示弹出窗口(更新,删除)。我使用TapGestureRecognizer_Tapped来获取已选择行的位置,但是我无法获取它的位置。 结果:单击后,我想在MoreOption的位置显示弹出窗口。
这里的代码:
内部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>
在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>
内部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);
}
内部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>
有什么办法可以解决这个问题?