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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DataSource doesnt work on UWP using XF ListView

Thread ID:

Created:

Updated:

Platform:

Replies:

128211 Jan 8,2017 10:12 PM UTC Jan 11,2017 06:12 AM UTC Xamarin.Forms 3
loading
Tags: DataSource
Emil
Asked On January 8, 2017 10:12 PM UTC

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)
            {
                 
            }
           
        }

Dinesh Babu Yadav [Syncfusion]
Replied On 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 
 


Emil
Replied On 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

Dinesh Babu Yadav [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;