Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

How to remove the selected item from FlowListView?

$
0
0

I need to remove the selected picture when clicks a cross image. For that, I added a cross image on top of the image and added the tapped event. I am showing the images in FlowListView.

MainPage.xaml

<flv:FlowListView 
        FlowColumnCount="3" 
        x:Name="listItems" 
        SeparatorVisibility="None"
        HasUnevenRows="false" 
        RowHeight="100" >
        <flv:FlowListView.FlowColumnTemplate>
            <DataTemplate>

                <StackLayout
                    Orientation="Vertical">

                    <Image 
                        Source="ic_close.png"
                        HeightRequest="20"
                        WidthRequest="20">
                        <Image.GestureRecognizers>
                            <TapGestureRecognizer
                            Tapped="RemoveImage"
                            NumberOfTapsRequired="1" />
                        </Image.GestureRecognizers>
                    </Image>

                    <Image 
                        AbsoluteLayout.LayoutFlags="All" 
                        HeightRequest="100" 
                        AbsoluteLayout.LayoutBounds="0,0,1,1" 
                        Source="{Binding .}"  
                        Aspect="AspectFill" 
                        HorizontalOptions="FillAndExpand">
                    </Image>
                </StackLayout>
            </DataTemplate>
        </flv:FlowListView.FlowColumnTemplate>
    </flv:FlowListView>

MainPage.xaml.cs

 public partial class MainPage : ContentPage
 {
    List<string> _images = new List<string>();
    public MainPage()
    {
        InitializeComponent();
    }

    protected override void OnAppearing()
    {
        base.OnAppearing();

        MessagingCenter.Subscribe<App, List<string>>((App)Xamarin.Forms.Application.Current, "ImagesSelected", (s, images) =>
        {
            listItems.FlowItemsSource = images;
            _images = images;
        });
    }

    protected override void OnDisappearing()
    {
        base.OnDisappearing();
        MessagingCenter.Unsubscribe<App, List<string>>(this, "ImagesSelected");
    }

    public void RemoveImage(Object sender, EventArgs args)
    {
        // How I can remove the selected image from the FlowListView
    }
}

Anybody, please suggest a way to remove that image from FlowListview?


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>