Expandable listview -innerlist is not showing

Hello , 

I have the following issue , Im trying to add a list that consumes an http call to generate the inner list as check boxes. 

the issue I have is all syncfusions examples are way to complicated to understand . Im attaching one that when you tapp on the outerlist item it generates another list  and then when the checkbox is check then it collapses again . 


issues 

  • the inner list is not showing 
  • when check on item inside the inner list it doesnt collapses .(after checking the checkbox it should collapses the inner list, )
  • how do I capture the checkbox selection object , can it display an alert after selecting the item and the collapses the
  • ON THE OUTER LIST I only want to display 3 items on the list and have a button that makes the list expand , I mean the outerlist 

on the HELPERS  folder you find this file 

using ExpandableListView.ViewModel;

using Syncfusion.ListView.XForms;

using System;

using System.Collections.Generic;

using System.Text;

using Xamarin.Forms;


namespace ExpandableListView

{

    public class Behavior : Behavior<ContentPage>

    {

        private SfListView listView;

        private SfListView listView2;

        private AccordionViewModel viewModel;

        private bookViewModel bookviewmodel;




        public Behavior()

        {

            viewModel = new AccordionViewModel();

            bookviewmodel = new bookViewModel();

        }


        protected override void OnAttachedTo(ContentPage bindable)

        {

            base.OnAttachedTo(bindable);

            listView = bindable.FindByName<SfListView>("listView");

            viewModel.listView = listView;

            listView.BindingContext = viewModel;

            listView.ItemsSource = viewModel.ContactsInfo;


            //newlist attemping to display the list from this behavior =>fail


          // listView2 = bindable.FindByName<SfListView>("listView2");

          // bookviewmodel.listView2 = listView2;

           // listView2.BindingContext = viewModel;

            //listView2.ItemsSource = bookviewmodel.ContactsInfo2;




        }

    }

}

on the folder model

using System.ComponentModel;

using Xamarin.Forms;


namespace ExpandableListView

{

    public class Contact : INotifyPropertyChanged

    {

        #region Fields


        private string contactName;

        private string callTime;

        private ImageSource contactImage;

        private ImageSource phoneImage;

        private bool isVisible = false;

        private ImageSource sendMessage;

        private ImageSource blockSpan;

        private ImageSource callDetails;

        private ImageSource addContact;

        private ImageSource newContact;


        #endregion


        #region Properties


        public bool IsVisible

        {

            get { return isVisible; }

            set

            {

                isVisible = value;

                this.RaisedOnPropertyChanged("IsVisible");

            }

        }


        public string ContactName

        {

            get { return contactName; }

            set

            {

                if (contactName != value)

                {

                    contactName = value;

                    this.RaisedOnPropertyChanged("ContactName");

                }

            }

        }


        public string CallTime

        {

            get { return callTime; }

            set

            {

                if (callTime != value)

                {

                    callTime = value;

                    this.RaisedOnPropertyChanged("CallTime");

                }

            }

        }


        public ImageSource ContactImage

        {

            get { return this.contactImage; }

            set

            {

                this.contactImage = value;

                this.RaisedOnPropertyChanged("ContactImage");

            }

        }


        private string bookName;

        private string bookDesc;


        public string BookName

        {

            get { return bookName; }

            set

            {

                bookName = value;

                this.RaisedOnPropertyChanged("BookName");

            }

        }


        public string BookDescription

        {

            get { return bookDesc; }

            set

            {

                bookDesc = value;

                this.RaisedOnPropertyChanged("BookDescription");

            }

        }



        public ImageSource AddContact

        {

            get { return this.addContact; }

            set

            {

                this.addContact = value;

                this.RaisedOnPropertyChanged("AddContact");

            }

        }


        public ImageSource NewContact

        {

            get { return this.newContact; }

            set

            {

                this.newContact = value;

                this.RaisedOnPropertyChanged("NewContact");

            }

        }


        public ImageSource SendMessage

        {

            get { return this.sendMessage; }

            set

            {

                this.sendMessage = value;

                this.RaisedOnPropertyChanged("SendMessage");

            }

        }


        public ImageSource BlockSpan

        {

            get { return this.blockSpan; }

            set

            {

                this.blockSpan = value;

                this.RaisedOnPropertyChanged("BlockSpan");

            }

        }


        public ImageSource CallDetails

        {

            get { return this.callDetails; }

            set

            {

                this.callDetails = value;

                this.RaisedOnPropertyChanged("CallDetails");

            }

        }


        public ImageSource PhoneImage

        {

            get { return this.phoneImage; }

            set

            {

                this.phoneImage = value;

                this.RaisedOnPropertyChanged("PhoneImage");

            }

        }


        #endregion


        #region Constrator


        public Contact()

        {


        }


        public Contact(string Name)

        {

            contactName = Name;

        }


        #endregion


        #region Interface Member


        public event PropertyChangedEventHandler PropertyChanged;


        public void RaisedOnPropertyChanged(string _PropertyName)

        {

            if (PropertyChanged != null)

            {

                PropertyChanged(this, new PropertyChangedEventArgs(_PropertyName));

            }

        }


        #endregion

    }

}


in the folder viewmodel 

using Syncfusion.ListView.XForms;

using Syncfusion.ListView.XForms.Control.Helpers;

using Syncfusion.ListView.XForms.Helpers;

using System;

using System.Collections.Generic;

using System.Collections.ObjectModel;

using System.ComponentModel;

using System.Linq;

using System.Reflection;

using System.Text;

using Xamarin.Forms;


namespace ExpandableListView

{

    public class AccordionViewModel : INotifyPropertyChanged

    {

        #region Fields


        int counter = 11;


        #endregion


        #region Properties


        public ObservableCollection<Contact> ContactsInfo { get; set; }


        private Contact TappedItem;

        internal SfListView listView;




        public Command<object> TapGestureCommand { get; set; }


        #endregion


        #region Constructor


        public AccordionViewModel()

        {

            ContactsInfo = new ObservableCollection<Contact>();


            Assembly assembly = typeof(ExpandableListView.MainPage).GetTypeInfo().Assembly;

            int i = 0;

            foreach (var cusName in CustomerNames)

            {

                if (counter == 13)

                    counter = 1;

                var contact = new Contact(cusName);

                contact.CallTime = CallTime[i];

                contact.PhoneImage = ImageSource.FromResource("ExpandableListView.Images.PhoneImage.png", assembly);

                contact.ContactImage = ImageSource.FromResource("ExpandableListView.Images.Image" + counter + ".png", assembly);

                contact.AddContact = ImageSource.FromResource("ExpandableListView.Images.AddContact.png", assembly);

                contact.NewContact = ImageSource.FromResource("ExpandableListView.Images.NewContact.png", assembly);

                contact.SendMessage = ImageSource.FromResource("ExpandableListView.Images.SendMessage.png", assembly);

                contact.BlockSpan = ImageSource.FromResource("ExpandableListView.Images.BlockSpan.png", assembly);

                contact.CallDetails = ImageSource.FromResource("ExpandableListView.Images.CallDetails.png", assembly);

                i++;

                if (ContactsInfo.Count > 2)

                {

                    ContactsInfo.RemoveAt(2);


                }

                ContactsInfo.Add(contact);

                counter++;

                // listView2.ItemsSource = ContactsInfo;



            }

            TapGestureCommand = new Command<object>(TappedGestureCommandMethod);

        }


        private ObservableCollection<Contact> bookInfo;


        public ObservableCollection<Contact> BookInfo

        {

            get { return bookInfo; }

            set { this.bookInfo = value; }

        }


        public void GenerateBookInfo()

        {

            bookInfo = new ObservableCollection<Contact>();

            bookInfo.Add(new Contact() { BookName = "Object-Oriented Programming in C#", BookDescription = "Object-oriented programming is a programming paradigm based on the concept of objects" });

            bookInfo.Add(new Contact() { BookName = "C# Code Contracts", BookDescription = "Code Contracts provide a way to convey code assumptions" });

            bookInfo.Add(new Contact() { BookName = "Machine Learning Using C#", BookDescription = "You’ll learn several different approaches to applying machine learning" });

            bookInfo.Add(new Contact() { BookName = "Neural Networks Using C#", BookDescription = "Neural networks are an exciting field of software development" });

            bookInfo.Add(new Contact() { BookName = "Visual Studio Code", BookDescription = "It is a powerful tool for editing code and serves for end-to-end programming" });

            bookInfo.Add(new Contact() { BookName = "Android Programming", BookDescription = "It is provides a useful overview of the Android application life cycle" });


            BookInfo= new ObservableCollection<Contact>(bookInfo) ;


        }



        private void TappedGestureCommandMethod(object obj)

        {

            var tappedItemData = obj as Contact;

            if (TappedItem != null && TappedItem.IsVisible)

            {

                TappedItem.IsVisible = false;

            }


            if (TappedItem == tappedItemData)

            {

                TappedItem = null;

                return;

            }


            TappedItem = tappedItemData;

            TappedItem.IsVisible = true;

        }

        #endregion


        #region Fields


        string[] CustomerNames = new string[] {

            "Kyle",

            "Gina",

            "Irene",

            "Katie",

            "Oscar",

            "Ralph",

            "Torrey",

            "William",

            "Bill",

            "Daniel",

            "Frank",

            "Brenda",

            "Danielle",

            "Fiona",

            "Howard",

            "Jack",

            "Larry",

            "Holly",

            "Liz",

            "Pete",

            "Steve",

            "Vince",

            "Katherin",

            "Aliza",

            "Masona" ,

            "Lia" ,


        };


        string[] CallTime = new string[]

        {

            "India, 1 days ago",

            "India, 1 days ago",

            "India, 1 days ago",

            "India, 1 days ago",

            "India, 1 days ago",

               };


        #endregion


        #region Interface Member


        public event PropertyChangedEventHandler PropertyChanged;


        public void OnPropertyChanged(string name)

        {

            if (this.PropertyChanged != null)

                this.PropertyChanged(this, new PropertyChangedEventArgs(name));

        }


        #endregion

    }

}

folder view

mainpage.xaml

<ContentPage x:Class="ExpandableListView.MainPage"

             xmlns="http://xamarin.com/schemas/2014/forms"

             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"

             xmlns:local="clr-namespace:ExpandableListView"

             xmlns:sflistview="clr-namespace:Syncfusion.ListView.XForms;assembly=Syncfusion.SfListView.XForms">


    <ContentPage.Behaviors>

        <local:Behavior/>

    </ContentPage.Behaviors>


    <ContentPage.Content>

        <Grid x:Name="mainGrid" BackgroundColor="#F0F0F0" Padding="4">

            <sflistview:SfListView x:Name="listView" AutoFitMode="DynamicHeight" SelectionMode ="None" IsScrollBarVisible="False" ItemSpacing="0">

                <sflistview:SfListView.ItemTemplate>

                    <DataTemplate>

                        <ViewCell>

                            <ViewCell.View>

                                <Grid Padding="2" Margin="1" BackgroundColor="#F0F0F0" >

                                    <Frame x:Name="frame" CornerRadius="2" Padding="1" Margin="1" OutlineColor="White">

                                        <Frame.HasShadow>

                                            <OnPlatform x:TypeArguments="x:Boolean" Android="True" WinPhone="True" iOS="False"/>

                                        </Frame.HasShadow>

                                        <Grid VerticalOptions="FillAndExpand" BackgroundColor="White" HorizontalOptions="FillAndExpand">

                                            <Grid.RowDefinitions>

                                                <RowDefinition Height="Auto" />

                                            </Grid.RowDefinitions>

                                            <Grid x:Name="grid" RowSpacing="0" Padding="0,4,0,0">

                                                <Grid.GestureRecognizers>

                                                    <TapGestureRecognizer Command="{Binding Path=BindingContext.TapGestureCommand, Source={x:Reference listView}}" CommandParameter="{Binding .}"/>

                                                </Grid.GestureRecognizers>

                                                <Grid.RowDefinitions>

                                                    <RowDefinition Height="60" />

                                                </Grid.RowDefinitions>

                                                <Grid RowSpacing="0">

                                                    <Grid.ColumnDefinitions>

                                                        <ColumnDefinition Width="60" />

                                                        <ColumnDefinition Width="*" />

                                                        <ColumnDefinition Width="50" />

                                                    </Grid.ColumnDefinitions>

                                                    <Image Grid.Row="0" Margin="3.5,1.5,0,0" Grid.Column="0" Source="{Binding ContactImage}" VerticalOptions="Center" Aspect="AspectFill"/>

                                                    <Grid Grid.Row="0" Grid.Column="1" RowSpacing="1" Padding="10,5,0,0" VerticalOptions="CenterAndExpand">

                                                        <Grid.RowDefinitions>

                                                            <RowDefinition Height="*" />

                                                            <RowDefinition Height="*" />

                                                        </Grid.RowDefinitions>

                                                        <Label Grid.Row="0" LineBreakMode="NoWrap" TextColor="#474747" Text="{Binding ContactName}"/>

                                                        <Label Grid.Row="1" TextColor="#474747" LineBreakMode="NoWrap" Text="{Binding CallTime}"/>

                                                    </Grid>

                                                    <Grid Grid.Row="0" Grid.Column="2" HorizontalOptions="Center" VerticalOptions="Center">

                                                        <Image Source="{Binding PhoneImage}" Opacity="0.60" HeightRequest="20" WidthRequest="20" HorizontalOptions="Center" VerticalOptions="Center" />

                                                    </Grid>

                                                </Grid>

                                            </Grid>

                                            <Grid IsVisible="{Binding IsVisible, Mode=TwoWay}" ColumnSpacing="0" RowSpacing="0" Grid.Row="1" BackgroundColor="White"

                            HorizontalOptions="FillAndExpand" Padding="5" VerticalOptions="FillAndExpand">

                                                <Grid.RowDefinitions>

                                                    <RowDefinition Height="1" />

                                                    <RowDefinition Height="40" />

                                                    <RowDefinition Height="40" />

                                                    <RowDefinition Height="40" />

                                                    <RowDefinition Height="40" />

                                                    <RowDefinition Height="40" />

                                                </Grid.RowDefinitions>

                                                <Grid.ColumnDefinitions >

                                                    <ColumnDefinition Width="50" />

                                                    <ColumnDefinition Width="*" />

                                                </Grid.ColumnDefinitions>

                                                <BoxView Grid.Row="0" Grid.Column="0" BackgroundColor="LightGray" />

<StackLayout>


     <!--<sflistview:SfListView x:Name="listView"

                   ItemsSource="{Binding BookInfo}"

                   ItemSize="100">

    <sflistview:SfListView.ItemTemplate>

        <DataTemplate>

        <Grid Padding="10">

            <Grid.RowDefinitions>

            <RowDefinition Height="0.4*" />

            <RowDefinition Height="0.6*" />

            </Grid.RowDefinitions>

            <Label Text="{Binding BookName}" FontAttributes="Bold" TextColor="Teal" FontSize="21" />

            <Label Grid.Row="1" Text="{Binding BookDescription}" TextColor="Teal" FontSize="15"/>

        </Grid>

        </DataTemplate>

    </sflistview:SfListView.ItemTemplate>

  </sflistview:SfListView>-->


</StackLayout>


                                                <Label Grid.Row="5" Grid.Column="1" Text="expandido" TextColor="#000000" FontSize="14" HorizontalOptions="Start"

                               VerticalOptions="Center" Opacity="87"/>

                                            </Grid>

                                        </Grid>

                                    </Frame>

                                </Grid>

                            </ViewCell.View>

                        </ViewCell>

                    </DataTemplate>

                </sflistview:SfListView.ItemTemplate>

            </sflistview:SfListView>

        </Grid>

    </ContentPage.Content>

</ContentPage>


Mainpage.cs 

public partial class MainPage : ContentPage

    {

        public MainPage()

        {

            InitializeComponent();


        }

    }



8 Replies 1 reply marked as answer

LN Lakshmi Natarajan Syncfusion Team February 23, 2022 01:23 PM UTC

Hi Pamela, 
 
Query 
Response 
the inner list is not showing 
We suggest you bind the ItemsSource for the inner ListView as mentioned below, 
 
<sflistview:SfListView x:Name="innerListView" Grid.Row="1" 
                                                                           ItemsSource="{Binding Path=BindingContext.BookInfo, Source={x:Reference listView}}" 
                                                                           ItemSize="100"  
                                                                           IsScrollingEnabled="False"> 
 
Since you have defined the BookInfo collection in the ViewModel class, you need to get the BookInfo property from the BindingContext of the ListView. 
 
when check on item inside the inner list it doesnt collapses .(after checking the checkbox it should collapses the inner list, ) 
We suggest you bind the IsVisible property to the CheckBox’s IsChecked property as mentioned below to achieve your requirement, 
 
<local:ExtendedListView.ItemTemplate> 
    <DataTemplate> 
        <ViewCell> 
            <ViewCell.View> 
                <Grid Padding="2" Margin="1" BackgroundColor="#F0F0F0" > 
                     
                                <buttons:SfCheckBox Text="{Binding ContactName, Mode=TwoWay}" IsChecked="{Binding IsChecked, Mode=TwoWay}"/> 
                            </Grid> 
                            <Grid IsVisible="{Binding IsChecked}" ColumnSpacing="0" RowSpacing="0" Grid.Row="1" BackgroundColor="White" 
            HorizontalOptions="FillAndExpand" Padding="5" VerticalOptions="FillAndExpand"> 
                                
                    </Frame> 
                </Grid> 
            </ViewCell.View> 
        </ViewCell> 
    </DataTemplate> 
</local:ExtendedListView.ItemTemplate> 
 
 
how do I capture the checkbox selection object , can it display an alert after selecting the item and the collapses the 
You can bind the SfListView.TapCommand and get the tapped item details from the ItemTappedEventArgs. 
 
Please refer to the following code snippets for more reference, 
private void TappedGestureCommandMethod(object obj) 
{ 
    var tappedItemData = (obj as Syncfusion.ListView.XForms.ItemTappedEventArgs).ItemData as Contact; 
    tappedItemData.IsChecked = !tappedItemData.IsChecked; //Update check box status 
 
    App.Current.MainPage.DisplayAlert("Tapped item", tappedItemData.ContactName, "Ok"); 
} 
 
You can also refer to our user guidance document regarding the same, 
 
ON THE OUTER LIST I only want to display 3 items on the list and have a button that makes the list expand , I mean the outerlist 
We have prepared a sample to achieve your requirement. 
 
Please refer to the sample and video in the following link, 
 
Please let us know if you need further assistance. 
 
Lakshmi Natarajan 
 



PR Pamela Rios February 24, 2022 03:15 AM UTC

Hi thanks a lot . However , as soon as I add the service to render the list , the list comes back as null . Tried many things to trigger the service . but it seems the behavior comes before the http call . let me show you . what I did . 

as reference : The outer list comes from a service called getCampusList(); and it the list gets consume by Active Campuses 

The inner list comes after you pressed a campus item, it takes the id and passes to the second service GETBUILDINGS() and it consumes by ActiveBuildings list . as follow Bddd

Behaviour ExtList

public class ExtList : Behavior<ContentPage>

    {

        private SfListView outerlist;

        private FiltersViewModel viewModel;

        Grid ExpandCollapse;

        bool IsExpanded;


        public ExtList()

        {

            viewModel = new FiltersViewModel();

        }



        protected override void OnAttachedTo(ContentPage bindable)

        {

            base.OnAttachedTo(bindable);

            ExpandCollapse = bindable.FindByName<Grid>("expandCollapseone");

            outerlist = bindable.FindByName<SfListView>("outerlist");

            outerlist.BindingContext = viewModel;


            var tapGesture = new TapGestureRecognizer();

            ExpandCollapse.GestureRecognizers.Add(tapGesture);


            tapGesture.Tapped += TapGesture_Tapped;


            outerlist.ItemsSource = viewModel.ActiveCampuses;//if we want to display only Take(3);

        }


        private void TapGesture_Tapped(object sender, EventArgs e)

        {

            this.IsExpanded = !this.IsExpanded;


            if (this.IsExpanded)

            {

                outerlist.ItemsSource = viewModel.ActiveCampuses;

            }

            else

            {

                outerlist.ItemsSource = viewModel.ActiveCampuses;//.Take(3);

            }

        }


    }



    public class ExtendedListViewone : SfListView

    {

        VisualContainer container;


        public ExtendedListViewone()

        {

            container = this.GetVisualContainer();

            container.PropertyChanged += Container_PropertyChanged;

        }



        private void Container_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)

        {

            Device.BeginInvokeOnMainThread(() =>

            {

                var extent = (double)container.GetType().GetRuntimeProperties().FirstOrDefault(container => container.Name == "TotalExtent").GetValue(container);

                if (e.PropertyName == "Height")

                    this.HeightRequest = extent;

            });


        }

    }



}

Constructor 

 public FiltersViewModel()

        {


            TapGestureCommand = new Command<object>(TappedGestureCommandMethod);


             GetCampusList();

        }

 private void TappedGestureCommandMethod(object obj)

        {

            var tappedItemData = (obj as Syncfusion.ListView.XForms.ItemTappedEventArgs).ItemData as FilterModel;

            var id = tappedItemData.id.ToString();

            GetBuildingsList(id);

          tappedItemData.IsChecked = !tappedItemData.IsChecked;


        }

The methods that gets the services are 

 public async void GetCampusList()

        {

 var response = await ConnectService

List = response;

 var info = mainCampusesList.Select(s => new FilterModel { name = s.name , CheckBoxText= s.name, id = s.id }).ToList();

   ActiveCampuses = new ObservableCollection<FilterModel>(info);


}

public async void GetBuildingsList(string id )

        {

           var response = await ConnectService.GetAvailableBuildingsPerCampus(id);

           BuildingsList = response;

                var info = BuildingsList.Select(s => new FilterModel { name = s.name, id = s.id,CheckBoxText=s.name       }).ToList();

                ActiveBuildings = new ObservableCollection<FilterModel>(info);


}


ObservableCollection<FilterModel> _activeBuildings;

        public ObservableCollection<FilterModel> ActiveBuildings

        {

            get { return _activeBuildings; }

            set

            {

                SetProperty(ref _activeBuildings, value);

            }

        }



ObservableCollection<FilterModel> _activeCampuses;

        public ObservableCollection<FilterModel> ActiveCampuses

        {

            get { return _activeCampuses; }

            set

            {

                SetProperty(ref _activeCampuses, value);

            }

        }


XAML 


<ContentPage.Behaviors>

        <local:MoreItemsBehavior/>

        <local4:ExtList/>

    </ContentPage.Behaviors>

  <StackLayout x:Name="mainGrid" BackgroundColor="#F0F0F0" Padding="4">

      <local4:ExtendedListViewone x:Name="outerlist"

                                  ItemsSource="{Binding ActiveCampuses}"

                                  AutoFitMode="DynamicHeight"

                                SelectionMode ="None" IsScrollBarVisible="False"

                                ItemSpacing="0"

                                TapCommand="{Binding TapGestureCommand}">

                <local4:ExtendedListViewone.ItemTemplate>

                    <DataTemplate>

                        <ViewCell>

                            <ViewCell.View>

                                <Grid Padding="2" Margin="1" BackgroundColor="#F0F0F0" >

                                    <Frame x:Name="frame" CornerRadius="2" Padding="1" Margin="1" OutlineColor="White">

                                        <Frame.HasShadow>

                                            <OnPlatform x:TypeArguments="x:Boolean" Android="True" WinPhone="True" iOS="False"/>

                                        </Frame.HasShadow>

                                        <Grid VerticalOptions="FillAndExpand" BackgroundColor="White" HorizontalOptions="FillAndExpand">

                                            <Grid.RowDefinitions>

                                                <RowDefinition Height="Auto" />

                                                <RowDefinition Height="Auto" />

                                            </Grid.RowDefinitions>

                                            <Grid x:Name="grid" RowSpacing="0" Padding="0,4,0,0">


       <btn:SfCheckBox x:Name="selectCheckBox" Text="{Binding CheckBoxText, Mode=TwoWay}" InputTransparent="True" UncheckedColor="#B0B0B0" IsChecked="{Binding IsChecked, Mode=TwoWay}" HorizontalOptions="Start" VerticalOptions="Center"/>


                                            </Grid>

                                            <Grid IsVisible="{Binding IsChecked}" ColumnSpacing="0" RowSpacing="0" Grid.Row="1" BackgroundColor="White"

                            HorizontalOptions="FillAndExpand" Padding="5" VerticalOptions="FillAndExpand">

                                                <Grid.RowDefinitions>

                                                    <RowDefinition Height="1" />

                                                    <RowDefinition Height="Auto" />

                                                    <RowDefinition Height="40" />

                                                </Grid.RowDefinitions>


                                                <BoxView Grid.Row="0" Grid.Column="0" BackgroundColor="LightGray" />

                                                    <sflistview:SfListView x:Name="innerListView" Grid.Row="1"

                          ItemsSource="{Binding Path=BindingContext.ActiveBuildings,

                                       Source={x:Reference outerlist}}"


                                                                           ItemSize="100"

                                                                           IsScrollingEnabled="False">

                                                        <sflistview:SfListView.ItemTemplate>

                                                            <DataTemplate>

                                                                <Grid Padding="10">

                                                                    <Grid.RowDefinitions>

                                                                        <RowDefinition Height="0.4*" />

                                                                        <RowDefinition Height="0.6*" />

                                                                    </Grid.RowDefinitions>

  <btn:SfCheckBox x:Name="selectCheckBox2" Text="{Binding CheckBoxText, Mode=TwoWay}" InputTransparent="True" UncheckedColor="#B0B0B0" IsChecked="{Binding IsChecked, Mode=TwoWay}" HorizontalOptions="Start" VerticalOptions="Center"/>


                                                               FontSize="15"/>

                                                                </Grid>

                                                            </DataTemplate>

                                                        </sflistview:SfListView.ItemTemplate>

                                                    </sflistview:SfListView>


                                                <Label Grid.Row="2" Text="expandido" TextColor="#000000" FontSize="14" HorizontalOptions="Start"

                               VerticalOptions="Center" Opacity="87"/>

                                            </Grid>

                                        </Grid>

                                    </Frame>

                                </Grid>

                            </ViewCell.View>

                        </ViewCell>

                    </DataTemplate>

                </local4:ExtendedListViewone.ItemTemplate>

            </local4:ExtendedListViewone>


            <Grid x:Name="expandCollapseone" HeightRequest="50">

                <Label Text="Show all accessibility features" FontSize="18" FontAttributes="Bold"/>

            </Grid>

        </StackLayout>






LN Lakshmi Natarajan Syncfusion Team February 24, 2022 12:54 PM UTC

Hi Pamela, 
 
We have modified our sample based on the code snippets provided and we are unable to replicate the issue on our end. We have populated our collection with delay in our sample. We have attached the tested sample in the following link, 
 
 
 
 
Please check our sample and let us know if still facing the same issue or not. If not, please modify our sample and revert us back with the following details, 
  • Issue replication sample
  • Issue replication video
  • Tested device details
  • Syncfusion and Xamarin.Forms versions
 
It will be helpful for us to check on it and provide you the solution at the earliest.  
 
Meanwhile, please ensure to invoke the PropertyChanged event for the collection to reflect the run time changes in the UI. Please refer to the following code snippets for more reference, 
 
public class FiltersViewModel : INotifyPropertyChanged 
{ 
    public Command<object> TapGestureCommand { get; set; } 
 
    ObservableCollection<FilterModel> _activeBuildings; 
    public ObservableCollection<FilterModel> ActiveBuildings 
    { 
        get { return _activeBuildings; } 
        set 
        { 
            _activeBuildings = value; 
            OnPropertyChanged("ActiveBuildings"); 
        } 
    } 
 
 
    ObservableCollection<FilterModel> _activeCampuses; 
    public ObservableCollection<FilterModel> ActiveCampuses 
    { 
        get { return _activeCampuses; } 
        set 
        { 
            _activeCampuses = value; 
            OnPropertyChanged("ActiveCampuses"); 
        } 
    } 
 
         
    public event PropertyChangedEventHandler PropertyChanged; 
    public void OnPropertyChanged(string name) 
    { 
        if (this.PropertyChanged != null) 
            this.PropertyChanged(this, new PropertyChangedEventArgs(name)); 
    } 
} 
 
You can also refer to our user guidance document regarding the same, 
 
Regards, 
Lakshmi Natarajan 



PR Pamela Rios February 25, 2022 01:47 AM UTC

Thanks again for your prompt response , I did tried your method but unfortunately , the view comes in first . I had to hardcode the list and it does works , but not with the http service . 

When I click on the expand label container , it does work however , when click it again to collapse , it does collapse by the number of items I specify . however , the empty space remains there . I\I tried to make it go away and it will collapse the item list but not the space. 


the other issue is that I can select the items inside the inner list . This is what I did .what I'm missing ?

Also , does sync fusion has any property that lets me go to the next step on my code , 

for example once the item selected on the inner list , instead of an alert I want it to collapse the inner list and scroll to another item in the page (another list )

Xaml 

 <sflistview:SfListView x:Name="innerListView" Grid.Row="1" TapCommand="{Binding TapGestureCommandone}"


                        ItemsSource="{Binding Path=BindingContext.ActiveBuildings,


                                    Source={x:Reference outerlist}}"     ItemSize="100"         IsScrollingEnabled="False">


     <btn:SfCheckBox x:Name="selectCheckBox2" Text="{Binding CheckBoxText, Mode=TwoWay}" InputTransparent="True" UncheckedColor="#B0B0B0" IsChecked="{Binding IsChecked, Mode=TwoWay}" HorizontalOptions="Start" VerticalOptions="Center"/>


on the view model 


 public Command<object> TapGestureCommandone { get; set; }


 public FiltersViewModel()

        {

            TapGestureCommand = new Command<object>(TappedGestureCommandMethod);

            TapGestureCommandone = new Command<object>(TappedGestureCommandMethodone);


            GetCampusList();

        }


private void TappedGestureCommandMethodone(object obj)

        {

            var tappedItemData = (obj as Syncfusion.ListView.XForms.ItemTappedEventArgs).ItemData as FilterModel;

            var id = tappedItemData.id.ToString();



            App.Current.MainPage.DisplayAlert("Tapped item", id, "Ok");

        }


                                      



LN Lakshmi Natarajan Syncfusion Team February 26, 2022 01:15 PM UTC

Hi Pamela, 
 
Query 
Response 
When I click on the expand label container , it does work however , when click it again to collapse , it does collapse by the number of items I specify . however , the empty space remains there . I\I tried to make it go away and it will collapse the item list but not the space. 
 
Please share the issue replication sample with issue replication sample to replicate the issue on our end. It will be helpful for us to check on it and provide you the solution at the earliest. 
the other issue is that I can select the items inside the inner list . This is what I did .what I'm missing ? 
 
Also , does sync fusion has any property that lets me go to the next step on my code ,  
 
for example once the item selected on the inner list , instead of an alert I want it to collapse the inner list and scroll to another item in the page (another list ) 
You can achieve your requirement by maintaining the previous tapped item and collapse when the inner item clicked.  
 
Also, we suggest you call the ScrollToRowIndex method to programmatically scroll to the next item. 
 
Please refer to the following code snippets for more reference, 
private void TappedGestureCommandMethodone(object obj) 
{ 
    var tappedItemData = (obj as Syncfusion.ListView.XForms.ItemTappedEventArgs).ItemData as FilterModel; 
    var id = tappedItemData.Id.ToString(); 
 
    PreviousTappedItem.IsChecked = false; 
 
    var nextindex = ListView.DataSource.DisplayItems.IndexOf(PreviousTappedItem) + 1; 
    ListView.LayoutManager.ScrollToRowIndex(nextindex, Syncfusion.ListView.XForms.ScrollToPosition.End, true); 
 
    App.Current.MainPage.DisplayAlert("Tapped item", id, "Ok"); 
} 
 
Please refer to our user guidance document regarding programmatic scrolling in SfListView, 
 
 
We have attached the tested sample to achieve your requirement in the following link, 
 
Please let us know if this helps. 
 
Lakshmi Natarajan 
 


Marked as answer

PR Pamela Rios February 28, 2022 08:13 PM UTC

Thanks a lot , very helpful



LN Lakshmi Natarajan Syncfusion Team March 2, 2022 04:31 AM UTC

Hi Pamela, 
 
We are glad that your requirement has been met at your time. Please let us know if you need further assistance. As always, we are happy to help you out. 
 
Lakshmi Natarajan 
 



PR Pamela Rios replied to Lakshmi Natarajan March 2, 2022 10:15 AM UTC

thanks a lot 


Loader.
Up arrow icon