我可以在不丢失触觉(触摸)反馈的情况下更改ListView单元格中的背景颜色吗?

Blu*_*eft 11 listview xamarin xamarin.forms

(我在Xamarin论坛上问过但没有得到回复,所以我在这里尝试)

在Xamarin表单中,BackgroundColorListView中的设置ItemTemplate 会导致触觉反馈被禁用.

有没有办法解决? 我想自定义列表项的颜色,但没有触觉反馈看起来像垃圾.

示例XAML:

 <ListView x:Name="list"
           ItemTapped="OnItemSelected"
           IsGroupingEnabled="True"
           GroupDisplayBinding="{Binding Key}"
           GroupShortNameBinding="{Binding Key}"
           HasUnevenRows="True"
           ItemsSource="{Binding .}">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
              <StackLayout VerticalOptions="FillAndExpand"
                           Padding="5, 20"
                           BackgroundColor="#CCCCCC"> <!--This line causes haptic feedback to fail -->
                <Label Text="{Binding Name}"
                       TextColor="Black"
                       VerticalOptions="Center"
                       FontSize="Large"/>
              </StackLayout>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>
Run Code Online (Sandbox Code Playgroud)

我已经得到最接近的是改变BackgroundColorViewCell.Tapped,那么改变它放回View.OnAppearing() (ViewCell.Appearing坏了),但是当手指抬起,而不是当的pressed它改变的背景.

我正在Android上测试,但更喜欢跨平台的解决方案.

Tom*_*ett 9

在Xamarin论坛上查看您的帖子以获取我的反馈.我有一个简单的插入式解决方案,叫做XFGloss.它是Xamarin.Forms的免费开源插件.该源可在GitHub上获得.还有一个NuGet包.它允许您将BackgroundColor值分配给标准XF单元格控件(TextCell,EntryCell等).XFGloss还添加了其他几个新属性.

如果您希望修复现有实现,可以查看我在此代码提交中为支持可视反馈所做的更改.