Решение 1:
Думал, вы сказали, что ViewCell имеет волнообразный эффект изменения цвета фона после щелчка. Вы можете поместить Stacklayout или Grid в список просмотра, который имеет только одну ViewCell.
в xaml
<StackLayout>
<ListView x:Name="listView">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Label TextColor="Black" Text="{Binding Content}"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
в коде позади
public class Data
{
public string Content { get; set; }
}
public partial class MainPage : ContentPage
{
public ObservableCollection<Data> MySource { get; set; }
public MainPage()
{
InitializeComponent();
BindingContext = this;
MySource = new ObservableCollection<Data>()
{
new Data() {Content="Click Me" },
};
listView.ItemsSource = MySource;
}
}
Решение 2:
Вы можете использовать пакет TouchView от nuget
Добавление пакета nuget в ваш проект Xamarin.Forms .netStandard / PCL и в проекты для вашей платформы (iOS и Android)
iOS: добавьте строку TouchViewRenderer.Initialize () в ваш AppDelegate
(сохранить из компоновщика)
using TouchEffect.iOS;
namespace YourApp.iOS
{
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
TouchViewRenderer.Initialize();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
}
}
в xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:YourApp"
xmlns:touch="clr-namespace:TouchEffect;assembly=TouchEffect"
x:Class="App11.MainPage">
<StackLayout>
<touch:TouchView
RegularBackgroundColor="LightGray"
PressedBackgroundColor="Gray"
PressedOpacity="1"
PressedAnimationDuration="100"
RegularAnimationDuration="100"
Padding="10, 5"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand"
Completed="Handle_TouchCompleted"
>
<Label Text="Click Me"
TextColor="Black"
FontSize="30"/>
</touch:TouchView>
</StackLayout>
</ContentPage>
в коде позади
private void Handle_TouchCompleted(TouchEffect.TouchView sender, TouchEffect.EventArgs.TouchCompletedEventArgs args)
{
// do something you want
}