When is SfListView.DataSourceDisplayItems filled and available?

I want to implement sorting and reordering.

For reordering I need the current sequence after the data is sorted.

When I use a button and I apply a listView.DataSource.SortDescriptor and I call listView.DataSource.Refresh I can receive the new sequence in listView.DataSource.DisplayItems.

But when I launch the page with my construct a SfListView and set the fresh new data source I can call listView.DataSource.Refresh or listView.DataSource.RefreshFilter or whatever. In the starting phase DisplayItems is always empty.

After what event I can retrieve the DisplayItems?

3 Replies

MK Muthu Kumaran Gnanavinayagam Syncfusion Team February 1, 2018 10:11 AM UTC

Hi Martin, 
 
We have checked your requirement from our side. You can get the DisplayItems initially in the SfListView’s Loaded event when you have bound the ItemsSource in XAML page or while initializing the page containing SfListView. 
Please refer the below code example. 
 
Code Example[C#]: 
public partial class MainPage : ContentPage 
{ 
  public MainPage() 
  { 
    InitializeComponent(); 
    listView.Loaded += ListView_Loaded; 
  } 
 
  private void ListView_Loaded(object sender, ListViewLoadedEventArgs e) 
  { 
    var displayItems = (sender as SfListView).DataSource.DisplayItems; 
  } 
} 
 
Please let us know if you require further assistance. 
 
Regards, 
G.Muthu kumaran. 



MR MRi February 1, 2018 12:17 PM UTC

This works!
Thanks


MK Muthu Kumaran Gnanavinayagam Syncfusion Team February 2, 2018 04:11 AM UTC

Hi Martin, 
 
Thanks for the valuable response. 
 
Regards, 
G.Muthu kumaran. 


Loader.
Up arrow icon