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
close icon

DataSource doesnt work on UWP using XF ListView

I implemented datasource on xamarin.forms listview as below. It works fine on Android but it doesnt work on UWP only group headers are displayed but not items.
I have checked your SampleBrowser-Forms application and there you have implemented a customlistview on UWP using CustomRenderer. Not sure if existing listview doesnt work on UWP or not.
Can you please shed some lights on this issue?

   listview.ItemTemplate = new DataTemplate(() =>
                {
                   
                    var label = new ExtendedLabel()
                    {
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        VerticalOptions = LayoutOptions.FillAndExpand,
                        Margin = new Thickness(10, 0),
                        TextColor = Color.Black,
                        FontSize = 12,
                        
                        VerticalTextAlignment = TextAlignment.Start,
                        BackgroundColor = Color.White,
                        LineBreakMode = LineBreakMode.WordWrap    
                    };
                    label.SetBinding(Label.TextProperty, new Binding("Name", BindingMode.Default,new Convertors.HtmltoTextConvertor(), null));
                 
                    var viewCell = new ViewCell() { View = label };
                    viewCell.BindingContextChanged += ViewCell_BindingContextChanged;
                    return viewCell;
                });
                dataSource.EndInit();
                listview.ItemsSource = dataSource.DisplayItems;
private DataSource setDetails()
        {
            DataSource dataSource = new DataSource();         
            dataSource.Source = ViewModel.Details;
           
            dataSource.GroupDescriptors.Add(new GroupDescriptor("Title")
            {
                PropertyName = "Title",
                KeySelector = (object obj1) =>
                {                    
                    var item = (obj1 as Models.Detail);
                    return item.Title.ToString();
                }
            });

           
            return dataSource;
        }
private  void ViewCell_BindingContextChanged(object sender, EventArgs e)
        {
            try
            {
                ViewCell viewCell = sender as ViewCell;             
                if ((viewCell.BindingContext is Models.Detail)==false)
                {
                    var label = new Label()
                    {
                        TextColor = Color.Black,
                        FontSize = 14,
                        HeightRequest = 30,
                        HorizontalTextAlignment = TextAlignment.Center,
                        VerticalTextAlignment = TextAlignment.Center,
                        BackgroundColor = Color.Gray
                    };
                    label.SetBinding(Label.TextProperty, new Binding("Key"));
                
                    viewCell.View = label;
                }
            }
            catch (Exception)
            {
                 
            }
           
        }

3 Replies

DB Dinesh Babu Yadav Syncfusion Team January 9, 2017 10:45 AM UTC

Hi Emil, 
 
Thank you for contacting Syncfusion support. 
 
We have analyzed the reported query “DataSource is not working on UWP platform using Xamarin Forms ListView ”at our end, but we were unable to reproduce the issue with our sample. 
Please find the sample link below 
 
 
Could you please check with the above sample? If the issue still reproduces at your end, please modify the above sample to reproduce the issue and update us with replication procedure or video link. So, that we could able to analyze the issue better and update you with appropriate solution. 
 
We have internally used DataSource in SfListView control. Hence we recommend you to use SfListView control, since it has in-built features like selection, grouping , header and footer, swiping etc., 
 
Please let us know if you need any further assistance.    
 
Regards, 
Dinesh Babu Yadav 
 



EM Emil January 10, 2017 10:19 PM UTC

Hi Dinesh,

thanks for this sample app. I have compared and actually I found out that line below never becomes true for me even all mapping is correct.

 if ((viewCell.BindingContext is GroupResult) == true)

 I had to change to like below. I dont know why but in my case it requires full type with namespace. not sure if you have any clue about it.

  if (viewCell.BindingContext is Syncfusion.DataSource.Extensions.GroupResult)

Cheers,

Emil


DB Dinesh Babu Yadav Syncfusion Team January 11, 2017 06:12 AM UTC

Hi Emil, 

Thanks for the update. We suspect that the reported issue may arise because of any one of the following scenarios.
 
 
1.      Have you used the “GroupResult” keyword as class name in your application? 
2.      Whether the “GroupResult” keyword is in the application namespace?  

If any of the above scenarios exists, to avoid the name conflict we should add the namespace for the property name. So, kindly ensure that there is no class or namespace named “GroupResult” in your application.
 
 
Please let us know if you require any further assistance. 
 
Regards, 
Dinesh Babu Yadav 


Loader.
Live Chat Icon For mobile
Up arrow icon