C# 如何在Xamarin中添加三点菜单
我是Xamarin的新手。 我想在我的应用程序中添加一个上下文菜单(如下图所示的三个点)。当我点击ListView的ItemTemplate中的三点图像时,必须显示菜单 下面是我期望的开始。如何在Xamarin中实现此要求 这方面的任何帮助都会非常有用C# 如何在Xamarin中添加三点菜单,c#,xaml,xamarin,C#,Xaml,Xamarin,我是Xamarin的新手。 我想在我的应用程序中添加一个上下文菜单(如下图所示的三个点)。当我点击ListView的ItemTemplate中的三点图像时,必须显示菜单 下面是我期望的开始。如何在Xamarin中实现此要求 这方面的任何帮助都会非常有用 您有两个选择。如果需要,您可以使用上下文菜单进行常规行为,或者如果您的需求很复杂,可以使用开源弹出窗口进行自定义 如果您是Xamarin的新手,那么我建议您使用第一种方法 方法1: 请参阅ListView中的 会更有帮助 你必须像下面这样做 &l
您有两个选择。如果需要,您可以使用上下文菜单进行常规行为,或者如果您的需求很复杂,可以使用开源弹出窗口进行自定义 如果您是Xamarin的新手,那么我建议您使用第一种方法 方法1: 请参阅ListView中的 会更有帮助 你必须像下面这样做
<ListView ItemsSource="{Binding Items}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.ContextActions>
<MenuItem Text="Share"
IconImageSource="share.png"
Command="{Binding Source={x:Reference contentPage}, Path=BindingContext.ShareCommand}"
CommandParameter="{Binding .}"/>
<MenuItem Text="Add to playlist"
Command="{Binding Source={x:Reference contentPage}, Path=BindingContext.AddToPlaylistCommand}"
CommandParameter="{Binding .}"/>
</ViewCell.ContextActions>
<Grid>
...
<Image Source="ThreeDottedIcon" Grid.Column="2" HorizontalOptions="End">
<Image.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ThreeDottedIconPopup}"/>
</Image.GestureRecognizers>
</Image>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
有关弹出窗口的NuGet软件包,请参阅
我希望这会有所帮助。,根据您的屏幕截图,您想为每个ListView项目添加菜单吗?我看到您为contentpage添加了工具栏项。我不希望看到图片ABOCVEY您的问题在前面询问上下文菜单时完全是误导性的。我现在已经编辑了我的答案。请检查。嗨,我需要这样的东西,但只是想知道这个插件是否加载?我的应用程序存放时间几乎接近2秒!!
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
...
<Image Source="ThreeDottedIcon" Grid.Column="2" HorizontalOptions="End">
<Image.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ThreeDottedIconPopup}"/>
</Image.GestureRecognizers>
</Image>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
private Command _threeDottedIconPopup;
public Command ThreeDottedIconPopup
{
get
{
return _threeDottedIconPopup?? (_threeDottedIconPopup= new Command(async () =>
{
await PopupNavigation.Instance.PushAsync(new ContextPopup(ParametersIfRequired));
}));
}
}