嗨,我使用Xamarin表單ListView,我想知道是否可以禁用基於特定綁定的上下文操作或在後面的代碼中。我可以根據條件禁用ViewCell.ContextActions
我爲整個應用程序使用一個GroupedListView,但它顯示基於用戶在做什麼的不同數據。有一個「管理你的收藏夾」功能,我希望用戶能夠在iOS上刷卡刪除或在Android上長按刪除ListItem,但我不希望這種行爲,如果列表顯示一些搜索結果還是其他什麼東西
<ViewCell.ContextActions>
<MenuItem Text="Delete" IsDestructive="true" CommandParameter="{Binding .}" Command="{Binding Path=BindingContext.OnDeleteCommand, Source={x:Reference Name=ListViewPage}}"/>
</ViewCell.ContextActions>
這並沒有禁用它...
<ViewCell.ContextActions IsEnabled="false"> //This IsEnabled does nothing
<MenuItem Text="Delete" IsDestructive="true" CommandParameter="{Binding .}" Command="{Binding Path=BindingContext.OnDeleteCommand, Source={x:Reference Name=ListViewPage}}"/>
</ViewCell.ContextActions>
我如何禁用ContextActions?我不希望用戶總是能夠滑動
感謝您的幫助,我查看了DataTemplateSelector,它看起來像是我的問題的一個很好的解決方案。我在ViewCell – stepheaw