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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Screen shows blank when the itemsource is binded in the xaml .

Thread ID:

Created:

Updated:

Platform:

Replies:

132822 Sep 22,2017 07:14 PM UTC Sep 25,2017 05:05 AM UTC Xamarin.Forms 1
loading
Tags: SfDataGrid
Nandini Nadig
Asked On September 22, 2017 07:14 PM UTC

Hi,

 Please find the project file attached. Could you please help me on this? I tried the example of the website. But when I say 

Itemsource = new ... In the code behind it works. Why does not it work from xaml?

Thanks,
Nandini

Attachment: GridExample_953b5ca3.zip

Ashok N [Syncfusion]
Replied On September 25, 2017 05:05 AM UTC

Hi Nandini, 
 
Thanks for contacting Syncfusion support.  
 
We have checked your codes and we noticed that there is a mismatch in the namespace of the collection class which you are trying to bind as ItemsSource. You used OrderInfoRepository is a BindingContext instead of ViewModel class and mistakenly used OrderInfoCollection instead of using OrdersInfo which is the actual name of the collection. Please refer the below code snippet and change the ItemsSource to {Binding OrdersInfo} to rectify the same. 
 
<?xml version="1.0" encoding="utf-8" ?> 
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
             xmlns:local="clr-namespace:GridExample.ViewModel" 
             x:Class="GridExample.MainPage" 
             xmlns:syncfusion="clr-namespace:Syncfusion.SfDataGrid.XForms;assembly=Syncfusion.SfDataGrid.XForms" > 
 
    <ContentPage.BindingContext> 
        <local:ViewModel x:Name="viewModel" /> 
    </ContentPage.BindingContext> 
 
    <ContentPage.Content> 
        <StackLayout> 
            <syncfusion:SfDataGrid x:Name="dataGrid" 
                               ItemsSource="{Binding OrdersInfo}"> 
            </syncfusion:SfDataGrid> 
        </StackLayout> 
    </ContentPage.Content> 
</ContentPage> 
 
ViewModel: 
 
private ObservableCollection<OrderInfo> ordersInfo; 
public ObservableCollection<OrderInfo> OrdersInfo 
{ 
    get { return ordersInfo; } 
    set { this.ordersInfo = value; RaisePropertyChanged("OrdersInfo"); } 
} 
 
Regards, 
Ashok 


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

;