listview content not displaying when using itemsource

I have listview and I insert list of data as itemsource for the list but the list item always not displaying and how I can refresh/update list data directly when new item added to list ?


llllllllll.png

this is my xaml :


         <StackLayout Margin="0,0,230,0"


                              VerticalOptions="Start"


                              Grid.Column="0"


                             Grid.Row="0"


                             Orientation="Vertical">


                    <StackLayout BackgroundColor="{DynamicResource Gray-Bg}">


                        <Grid


            ColumnDefinitions="*, Auto"


            RowDefinitions="Auto, 1"


            RowSpacing="0"


                   >




                            <!-- Table number -->




                            <Label


                Grid.Row="0"


                Grid.Column="0"


                Grid.ColumnSpan="2"


                Margin="16,16,16,5"


                HorizontalOptions="Start"


                Style="{StaticResource TitleLabelStyle}"


                Text="10" />


                            <!-- Order State -->


                            <Label


                Grid.Row="0"


                Grid.Column="1"


                Grid.ColumnSpan="2"


                Margin="16,16,16,5"


                HorizontalOptions="End"


                Style="{StaticResource TitleLabelStyle}"


                Text="Active"


                TextTransform="Uppercase"/>


                        </Grid>


                        <Grid


            ColumnDefinitions="*, Auto"


            RowDefinitions="Auto, 1, Auto, Auto, Auto, Auto, 1, Auto"


            RowSpacing="0">


                            <buttons:SfButton


                               Grid.Column="0"


                                Grid.Row="0"


                                Grid.ColumnSpan="2"


                                Text="PICK UP"


                                HorizontalOptions="Start"


                                Margin="5,10,16,3"


                                TextColor="{StaticResource PrimaryColor}"


                               Style="{StaticResource TransparentButtonStyle}"


                            />


                            <buttons:SfButton


                               Grid.Column="1"


                                Grid.Row="0"


                                Text="ADD CUSTOMERS"


                                HorizontalOptions="End"


                                Grid.ColumnSpan="2"


                                Margin="16,10,0,3"


                                TextColor="{StaticResource PrimaryColor}"


                            Style="{StaticResource TransparentButtonStyle}"


                            />


                        </Grid>


                    </StackLayout>








                          <!-- Order listView -->




   <StackLayout

                            BackgroundColor="White" Orientation="Vertical"

                        HorizontalOptions="Start">

                       <sync:SfListView

                            x:Name="OrdersItemslist"

                                       IsVisible="true"

                                   AllowSwiping="True"

                                         SelectionMode="None"

                                       HeightRequest="568"

                                   ItemSize="50"

                           IsScrollingEnabled="True"

                           IsScrollBarVisible="True">

                            <sync:SfListView.ItemTemplate>

                                <DataTemplate>

                                    <ViewCell>

                                        <ViewCell.View>

                                            <Grid>

                                                <Grid.RowDefinitions>

                                                    <RowDefinition Height="*" />

                                                </Grid.RowDefinitions>

                                                <Label Grid.Row="0" Text="{Binding OrderName}" FontSize="20" TextColor="red"/>

                                            </Grid>

                                        </ViewCell.View>

                                    </ViewCell>

                                </DataTemplate>

                            </sync:SfListView.ItemTemplate>

                            <sync:SfListView.LayoutManager>

                                <sync:GridLayout SpanCount="1"/>

                            </sync:SfListView.LayoutManager>

                        </sync:SfListView>

                    </StackLayout>







                    <StackLayout>


                        <Grid


                        BackgroundColor="{StaticResource PrimaryColor}"


                        ColumnDefinitions="*, Auto"


                        RowDefinitions="Auto, 1"


                        RowSpacing="1">


                            <Label


                Grid.Row="0"


                Margin="16,12,16,16"


                HorizontalOptions="Start"


                LineHeight="{OnPlatform Android=1.25,


                                        Default=-1}"


                Style="{StaticResource TitleLabelStyle}"


                Text="Total"


                FontSize="Medium"


                TextColor="{StaticResource PrimaryText}"/>


                            <Label


                Grid.Row="0"


                Grid.Column="1"


                Margin="16,12,16,16"


                HorizontalOptions="EndAndExpand"


                HorizontalTextAlignment="End"


                LineHeight="OnPlatform Android=1.25,


                                        Default=-1}"


                Style="{StaticResource TitleLabelStyle}"


                Text="{Binding TotalOrderPrice, StringFormat='{0} SR'}"


                 TextColor="{StaticResource PrimaryText}"


                FontSize="Medium"/>


                        </Grid>


                    </StackLayout>


                </StackLayout>






and this is my code:




    private static ObservableCollection<Order> myList;


        public static ObservableCollection<Order> MyList

        {

            get { return myList; }

            set { myList = value; }

        }


 public CartPage(Order orderlist)

        {

            this.InitializeComponent();

            MyList.Add(new Order()

            {

                OrderId = orderlist.OrderId,

                OrderName = orderlist.OrderName,

                OrderQuantity = orderlist.OrderQuantity,

                OrderSize = orderlist.OrderSize,

                OrderState = orderlist.OrderState,

                OrderTotalPrice = orderlist.OrderTotalPrice,

                OrderUnitPrice = orderlist.OrderUnitPrice,

                OptionList = orderlist.OptionList

            });


//Mylist have 3 items inside it

            OrdersItemslist.ItemsSource = MyList;

            OrdersItemslist.IsVisible = true;

          // OrdersItemslist.RefreshView();

        }


8 Replies

ET etawreed July 13, 2021 11:45 AM UTC

below here is the itemsource = MyList and contain data 


xxx.png



LN Lakshmi Natarajan Syncfusion Team July 14, 2021 12:31 PM UTC

Hi etawreed, 
 
Thank you for using Syncfusion products. 
 
We have checked the reported query “listview content not displaying when using itemsource” from our side. We have prepared a sample based on the code snippets provided and we could not reproduce the reported scenario at our side.  
 
Please refer to the tested sample in the following link, 
 
 
 
Could you please check our sample and let us know if you still facing the same issue?  
 
We suspect that the items not displayed due to the improper binding. Please ensure that binding error occurs or not in the output window. If yes, we suggest you resolve the binding errors to overcome the reported scenario. 
 
Also, could you please share the following details to check further from our side, 
  • Share Order class code snippets
  • Share orderlist data
  • Share issue reproducing video
  • Share Syncfusion and Xamarin.Forms versions
 
Regards, 
Lakshmi Natarajan 



ET etawreed replied to Lakshmi Natarajan July 14, 2021 01:20 PM UTC

here is my order class :

b4.png

and I take the orderlist data from this popuo using this code :

b1.png

when click button the data will sent to CartPage class :

in the CartPage there are 2 constructor 1- default and the second constructor will Fills the data in the list and this is the code :

b2.png

and this is my xaml for listview :

b3.png

this is the popup screen and take the data from it:

b5.png

finally the list will be shown in left white space after click add to cart button :

bi.png




the xamarin form version is 5.0.0.2012

the syncfusion version is 19.2.0.44



ET etawreed replied to Lakshmi Natarajan July 15, 2021 08:57 AM UTC

It still does not appear and I have attached pictures of the code and screens. Is there a suggestion for help?



LN Lakshmi Natarajan Syncfusion Team July 15, 2021 12:02 PM UTC

Hi etawreed, 
 
Thank you for the update. 
 
Based on the code snippets provided, we could reproduce the reported scenario at our side. We would like to inform you that the reported scenario occurs since you are creating separate instance of the ChatPage with data for ListView, but the new ChatPage is not added to the application. In other words, we need to add the page to the pages stack when creating a new page at run time. 
 
Please refer to the following code snippets to replace the new page to the existing page,   
private void SfButton_Clicked(object sender, EventArgs e) 
{ 
    Random r = new Random(); 
             
    var 0 = new Order(); 
    ... 
 
    CartPage cartPage = new CartPage(o); 
 
    //Add the new page to the MainPage instance. 
    App.Current.MainPage = cartPage; 
 
    //CloseAllPopup 
    this.IsOpen = false; 
 
} 
 
Please let us know if you need further assistance. 
 
Lakshmi Natarajan 
 



ET etawreed replied to Lakshmi Natarajan July 15, 2021 12:39 PM UTC

I do the same what u say but here is the result :

ssssssssssssssssssssssssssssssss.png



ET etawreed replied to Lakshmi Natarajan July 15, 2021 03:40 PM UTC

thank u the problem solved



LN Lakshmi Natarajan Syncfusion Team July 16, 2021 04:38 AM UTC

Hi Etawreed, 
 
Thank you for the update. 
 
We are glad that the reported issue has been resolved at your side. Please let us know if you need further assistance. As always we are happy to help you out. 
 
Lakshmi Natarajan 
 


Loader.
Up arrow icon