|
private async void ListView_ItemTapped(object sender, Syncfusion.ListView.XForms.ItemTappedEventArgs e)
{
await Task.Delay(350);
await App.Current.MainPage.Navigation.PushAsync(new NewPage());
} |
|
xmlns:local="clr-namespace:ListViewXamarin"
xmlns:sync="clr-namespace:Syncfusion.ListView.XForms;assembly=Syncfusion.SfListView.XForms"
xmlns:effectsView="clr-namespace:Syncfusion.XForms.EffectsView;assembly=Syncfusion.Core.XForms"
x:Class="ListViewXamarin.MainPage"
Visual="Default">
<ContentPage.BindingContext>
<local:ViewModel />
</ContentPage.BindingContext>
<Grid RowSpacing="0" ColumnSpacing="0" Padding="0" Margin="0">
<sync:SfListView x:Name="listView" AutoFitMode="Height" ItemsSource="{Binding BookInfo}" SelectionBackgroundColor="#d3d3d3">
<sync:SfListView.ItemTemplate>
<DataTemplate>
<effectsView:SfEffectsView AnimationCompleted="SfEffectsView_AnimationCompleted">
<Grid Padding="0,12,8,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="1" />
</Grid.RowDefinitions>
<StackLayout Orientation="Vertical" Padding="8,0,8,10" VerticalOptions="Start" Grid.Row="0">
<Label Text="{Binding BookName}" FontAttributes="Bold" FontSize="16" TextColor="#000000" />
<Label Text="{Binding BookAuthor}" Grid.Row="1" FontSize="14" Opacity=" 0.67" TextColor="#000000" />
<Label Text="{Binding BookDescription}" Opacity=" 0.54" TextColor="#000000" FontSize="13"/>
</StackLayout>
<BoxView Grid.Row="1" HeightRequest="1" Opacity="0.75" BackgroundColor="#CECECE" />
</Grid>
</effectsView:SfEffectsView>
</DataTemplate>
</sync:SfListView.ItemTemplate>
</sync:SfListView>
</Grid>
</ContentPage> |
|
private void SfEffectsView_AnimationCompleted(object sender, EventArgs e)
{
Navigation.PushAsync(new NewPage());
} |
|
<sync:SfListView x:Name="listView" AutoFitMode="Height" ItemsSource="{Binding BookInfo}" SelectionBackgroundColor="#d3d3d3">
<sync:SfListView.ItemTemplate>
<DataTemplate>
<Grid Padding="0,12,8,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="1" />
</Grid.RowDefinitions>
<StackLayout Orientation="Vertical" Padding="8,0,8,10" VerticalOptions="Start" Grid.Row="0">
<Label Text="{Binding BookName}" FontAttributes="Bold" FontSize="16" TextColor="#000000" />
<Label Text="{Binding BookAuthor}" Grid.Row="1" FontSize="14" Opacity=" 0.67" TextColor="#000000" />
<Label Text="{Binding BookDescription}" Opacity=" 0.54" TextColor="#000000" FontSize="13"/>
</StackLayout>
<BoxView Grid.Row="1" HeightRequest="1" Opacity="0.75" BackgroundColor="#CECECE" />
</Grid>
</DataTemplate>
</sync:SfListView.ItemTemplate>
<sync:SfListView.SelectedItemTemplate>
<DataTemplate>
<effectsView:SfEffectsView x:Name="effectsView" IsSelected="True">
<effectsView:SfEffectsView.Behaviors>
<local:EffectsViewBehavior/>
</effectsView:SfEffectsView.Behaviors>
<Grid Padding="0,12,8,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="1" />
</Grid.RowDefinitions>
<StackLayout Orientation="Vertical" Padding="8,0,8,10" VerticalOptions="Start" Grid.Row="0">
<Label Text="{Binding BookName}" FontAttributes="Bold" FontSize="16" TextColor="#000000" />
<Label Text="{Binding BookAuthor}" Grid.Row="1" FontSize="14" Opacity=" 0.67" TextColor="#000000" />
<Label Text="{Binding BookDescription}" Opacity=" 0.54" TextColor="#000000" FontSize="13"/>
</StackLayout>
<BoxView Grid.Row="1" HeightRequest="1" Opacity="0.75" BackgroundColor="#CECECE" />
</Grid>
</effectsView:SfEffectsView>
</DataTemplate>
</sync:SfListView.SelectedItemTemplate>
</sync:SfListView> |
|
public class EffectsViewBehavior : Behavior<SfEffectsView>
{
#region Fields
SfEffectsView EffectsView;
#endregion
protected override void OnAttachedTo(SfEffectsView bindable)
{
EffectsView = bindable as SfEffectsView;
EffectsView.SelectionChanged += EffectsView_SelectionChanged;
EffectsView.AnimationCompleted += EffectsView_AnimationCompleted;
base.OnAttachedTo(bindable);
}
private void EffectsView_AnimationCompleted(object sender, EventArgs e)
{
var args = ((sender as SfEffectsView).BindingContext as BookInfo).TappedEventArgs;
App.Current.MainPage.Navigation.PushAsync(new NewPage());
}
private void EffectsView_SelectionChanged(object sender, EventArgs e)
{
EffectsView.ApplyEffects();
}
} |
|
public ItemTappedEventArgs TappedEventArgs
{
get { return tappedEventArgs; }
set
{
tappedEventArgs = value;
OnPropertyChanged("TappedEventArgs");
}
} |
|
private void ListView_ItemTapped(object sender, Syncfusion.ListView.XForms.ItemTappedEventArgs e)
{
(e.ItemData as BookInfo).TappedEventArgs = e;
} |