GithubHelp home page GithubHelp logo

syncfusionexamples / effectsview-listview-xamarin.forms Goto Github PK

View Code? Open in Web Editor NEW
0.0 5.0 0.0 984 KB

This repository contains sample about how to use effects view in ListView (SfListView) Xamarin.Forms ?

C# 100.00%
selection xamarin xamarin-forms listview effects effects-view itemtemplate scale selecteditemtemplate

effectsview-listview-xamarin.forms's Introduction

How to use effects view in ListView (SfListView) Xamarin.Forms ?

You can integrate the SfEffects in Xamarin.forms SfListView by loading the SfEffectsView as the content of ItemTemplate or SelectedItemTemplate.

Xaml: SfEffectsView added as the content of SelectedItemplate with Scale and Selection effects.

<sync:SfListView x:Name="listView"
                AutoFitMode="Height" 
                SelectionMode="Single"
                ItemsSource="{Binding BookInfo}">
    <sync:SfListView.SelectedItemTemplate>
        <DataTemplate>
            <Grid>
                <effects:SfEffectsView x:Name="effectsView"
                                       SelectionColor="LightSeaGreen"
                                       FadeOutRipple="True"
                                       RippleAnimationDuration="1000"
                                       IsSelected="True">
                    <effects:SfEffectsView.Behaviors>
                        <local:Behavior/>
                    </effects:SfEffectsView.Behaviors>
                    <StackLayout>
                        <Label Text="{Binding BookName}" FontSize="21"
                               FontAttributes="Bold"/>
                        <Label Grid.Row="1" Text="{Binding BookDescription}"
                               FontSize="15"/>
                    </StackLayout>
                </effects:SfEffectsView>
            </Grid>
        </DataTemplate>
    </sync:SfListView.SelectedItemTemplate>
</sync:SfListView>

C#: Programmatically apply effects to the SelectedItem.

public class Behavior : Behavior<SfEffectsView>
{
    protected override void OnAttachedTo(SfEffectsView bindable)
    {
        bindable.SelectionChanged += Bindable_SelectionChanged;
        base.OnAttachedTo(bindable);
    }

    private void Bindable_SelectionChanged(object sender, EventArgs e)
    {
        Device.BeginInvokeOnMainThread(() =>
        {
            var effectsView = sender as SfEffectsView;
            effectsView.ScaleFactor = 0.85;
            effectsView.ApplyEffects(SfEffects.Scale);
        });
    }
    protected override void OnDetachingFrom(SfEffectsView bindable)
    {
        bindable.SelectionChanged -= Bindable_SelectionChanged;
        base.OnDetachingFrom(bindable);
    }
}

Output

effectsview-listview-xamarin.forms's People

Contributors

jayaleshwari avatar sarubala20 avatar vinothkumar-ganesan avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.