We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to get the selected item from ListView while using EffectsView within ItemTemplate

Platform: Xamarin.Forms |
Control: SfEffectsView

This section explains how to get selected item from ListView while using SfEffectsView within ItemTemplate.

Consider the use case of showing list of employee names in first page and displaying their corresponding role in second page depending upon the user selection in Xamarin.Forms application as below.

EffectsView

Getting selected item of Listview can be achieved using AnimationCompleted event of SfEffectsView as shown in below code snippet.

XAML

<StackLayout>
        <ListView x:Name="listView"
                         ItemsSource="{Binding Data}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <syncfusion:SfEffectsView TouchDownEffects="Ripple"                                                   AnimationCompleted="OnEffectsViewAnimationCompleted">
                            <Label Text="{Binding Name}"/>
                        </syncfusion:SfEffectsView>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView> </StackLayout>

C#

private void OnEffectsViewAnimationCompleted(object sender, EventArgs e)
        {
            var effectsView = sender as SfEffectsView;
            selectedItem = effectsView.BindingContext as Model;
 
            Navigation.PushAsync(new SecondPage { BindingContext = selectedItem });
        }

 

Note:

When the effects are rendered on direct interaction, the AnimationCompleted event occurs on touchup, and when it is applied programmatically it is triggered immediately on completion of effects.


See also:
How to use effects view in listview(SfListview) xamarin-forms

Also refer our feature tour page to know more about the features available in our effectsview.
 

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile