gpt4 book ai didi

listview - Xamarin Forms ListView onpressing 事件

转载 作者:行者123 更新时间:2023-12-04 17:58:32 25 4
gpt4 key购买 nike

我想在按下项目时通过绑定(bind)(以编程方式)更改 IconToShow 属性来更改图像。

如何触发 OnPress 事件??

<ListView x:Name="listView" ItemSelected="OnItemSelected" ItemsSource="{Binding MainMenuList}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" IsVisible="{Binding MenuStyle, Converter={StaticResource not}" SeparatorColor="Blue">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Source="{Binding IconToShow}" Grid.Row="0" Grid.Column="1"/>
<Label Text="{Binding Title}" Grid.Row="0" Grid.Column="3"/>
</Grid>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>

最佳答案

因此,对于单元格内的 LongPress 事件,您需要单元格的自定义渲染器来执行您需要的操作,这里有一些链接可以帮助您:

https://forums.xamarin.com/discussion/58487/listview-long-press-tap-delete-popup

https://forums.xamarin.com/discussion/18798/detect-long-tap-on-listview-item

https://forums.xamarin.com/discussion/27323/how-can-i-recognize-long-press-gesture-in-xamarin-forms

希望这对您有所帮助。

关于listview - Xamarin Forms ListView onpressing 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38304300/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com