【发布时间】:2016-12-29 05:55:00
【问题描述】:
(我在Xamarin forums 上询问但没有得到回复,所以我在这里尝试)
在 Xamarin 表单中,在 ListView 中设置 BackgroundColor ItemTemplate causes haptic-feedback to be disabled。
有什么办法可以解决这个问题吗?我想自定义列表项的颜色,但没有触觉反馈看起来像垃圾。
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>
我得到的最接近的方法是将BackgroundColor 更改为ViewCell.Tapped,然后将其更改回View.OnAppearing() (ViewCell.Appearing 已损坏),但是当手指是抬起的,而不是按下时。
我正在 Android 上进行测试,但更喜欢跨平台解决方案。
【问题讨论】:
标签: listview xamarin xamarin.forms