https://learn.microsoft.com/zh-cn/dotnet/maui/fundamentals/behaviors?view=net-maui-7.0
<ListView x:Name="listView"
ItemsSource="{Binding Monkeys}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.ContextActions>
<MenuItem Text="Favorite"
Command="{Binding Source={x:Reference listView}, Path=BindingContext.FavoriteCommand}"
CommandParameter="{Binding}" ></MenuItem>
<MenuItem Text="Delete"
Command="{Binding Source={x:Reference listView}, Path=BindingContext.DeleteCommand}"
CommandParameter="{Binding}" ></MenuItem>
</ViewCell.ContextActions>
...
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
https://learn.microsoft.com/zh-cn/dotnet/maui/fundamentals/data-binding/commanding?view=net-maui-7.0
https://www.cnblogs.com/lesliexin/p/16433623.html
数据事件绑定和获取
https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/gestures/tap?view=net-maui-7.0
<Image
Source="book_fspsydj.png"
Aspect="AspectFill"
WidthRequest="162" >
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnTapGestureRecognizerTapped"
Buttons="Primary,Secondary"
CommandParameter="{Binding Name}"
></TapGestureRecognizer>
</Image.GestureRecognizers>
</Image>
void OnTapGestureRecognizerTapped(object sender, TappedEventArgs args)
{
// Handle the tap
if (args.Buttons == ButtonsMask.Secondary)
{
// Do something
}
}
文档更新时间: 2023-04-03 10:38 作者:admin