nothing display using sflistview

Hey Team , 

I had using sflistview for my stock take project ,but no items display when i migrate my project to syncfusion 

. by the way , it will show all the record n items if i using xamarin form list view .

please advise


4 Replies

AN ANSON March 16, 2022 04:44 AM UTC

<?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:buttons="clr-namespace:Syncfusion.XForms.Buttons;assembly=Syncfusion.Buttons.XForms"

             xmlns:listView="clr-namespace:Syncfusion.ListView.XForms;assembly=Syncfusion.SfListView.XForms"

               xmlns:vm="clr-namespace:APP_MPOS.Models"

             x:Class="APP_MPOS.Views.StockTake">

    <!--<ContentPage.BindingContext>

        <vm:MobileDoc/>

    </ContentPage.BindingContext>-->

    <ContentPage.Content>

        <Grid>

            <Grid.RowDefinitions>

                <RowDefinition Height="auto"/>

                <RowDefinition Height="*"/>

            </Grid.RowDefinitions>

            <StackLayout Grid.Row="0">

                <SearchBar/>


            </StackLayout>


            <ScrollView Grid.Row="1" Padding="6">


                <listView:SfListView x:Name="lstViewData"

                                     AutoFitMode="Height"

                                    ItemsSource="listMobileDoc"

                                     >

                    <listView:SfListView.ItemTemplate >

                        <DataTemplate>

                            <ViewCell>

                                <ViewCell.View>

                            <!--<Grid>

                                <Grid.RowDefinitions>

                                    <RowDefinition Height="auto"/>

                                    <RowDefinition Height="auto"/>

                                    <RowDefinition Height="auto"/>


                                </Grid.RowDefinitions>

                                <Grid.ColumnDefinitions>

                                    <ColumnDefinition Width="88"/>

                                    <ColumnDefinition Width="auto"/>

                                    <ColumnDefinition Width="auto"/>

                                </Grid.ColumnDefinitions>


                                <Label Text="{Binding DocumentNo}"

                                           Grid.Row="0" Grid.Column="2"

                                           TextColor="Maroon" FontSize="Medium" FontAttributes="Bold"/>


                                <Label Grid.Column="1" Grid.Row="0"

                                      Text="{Binding WarehouseCode}"

                                      FontSize="18" FontAttributes="Bold" TextColor="Black"/>


                                <Label Text="{Binding DocumentDate}"

                                           Grid.Row="1" Grid.Column="2"

                                           HorizontalOptions="EndAndExpand"

                                           TextColor="Black" FontSize="15"/>

                                <Label Text="{Binding TotalItems}" VerticalOptions="End" HorizontalOptions="End"

                                            Grid.Row="2" Grid.Column="2"/>

                                <Label Text="{Binding TotalQty}"

                                            Grid.Row="2" Grid.Column="1" VerticalOptions="End" HorizontalOptions="End"/>

                                <StackLayout Grid.Column="0" Grid.Row="0" Grid.RowSpan="3">

                                    <Image Source="send.png" WidthRequest="25" HeightRequest="25" x:Name="Send_Image" Aspect="AspectFit">

                                        <Image.GestureRecognizers>

                                            <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped_1" NumberOfTapsRequired="1"/>


                                        </Image.GestureRecognizers>

                                    </Image>

                                </StackLayout>

                            </Grid>-->

                                <Label Text="{Binding DocumentNo}"


                                           TextColor="Maroon" FontSize="Medium" FontAttributes="Bold"/>

                                </ViewCell.View>

                            </ViewCell>

                        </DataTemplate>

                    </listView:SfListView.ItemTemplate>


                </listView:SfListView>


            </ScrollView>


            <!--<buttons:SfButton Grid.Row="1" x:Name="BtnNewStockTake" Clicked="BtnNewStockTake_Clicked" CornerRadius="8" ShowIcon="True" ImageSource="add.png"

                    Text="New Document" WidthRequest="150" HeightRequest="50" Margin="0,0,20,120" HorizontalOptions="End" VerticalOptions="End"/>


            <buttons:SfButton Grid.Row="1" x:Name="BtnFilter" CornerRadius="8" ShowIcon="True" ImageSource="filter.png"

                    Text="Filter" WidthRequest="150" HeightRequest="50" Margin="0,0,20,50" HorizontalOptions="End" VerticalOptions="End"/>-->

        </Grid>

    </ContentPage.Content>

</ContentPage>

this is my xaml



AN ANSON March 16, 2022 04:46 AM UTC

this is my view model



AN ANSON March 16, 2022 04:46 AM UTC

using System;

using System.Collections.Generic;

using System.Text;

using SQLite;


namespace APP_MPOS.Models

{

public class MobileDoc

{

[PrimaryKey, AutoIncrement]

public int ID { get; set; }

public int ReferenceID { get; set; }


[MaxLength(30), Indexed, NotNull]

public string DocumentNo { get; set; }

public DateTime DocumentDate { get; set; }


[MaxLength(20)]

public string TerminalCode { get; set; }


public int AccountID { get; set; }

[MaxLength(20)]

public string AccountCode { get; set; }


[MaxLength(100)]

public string Remarks { get; set; }


public byte Type { get; set; }

public byte Status { get; set; }


public int WarehouseID { get; set; }

public int WarehouseReferenceID { get; set; }


[MaxLength(20)]

public string WarehouseCode { get; set; }


[MaxLength(20)]

public string WarehouseReferenceCode { get; set; }


public decimal TotalItems { get; set; }

public decimal TotalQty { get; set; }

public decimal TotalAmt { get; set; }

public DateTime CreationDate { get; set; }

public DateTime LastUpdateDate { get; set; }

public DateTime SyncDate { get; set; }

}


}

this is my model



LN Lakshmi Natarajan Syncfusion Team March 16, 2022 01:41 PM UTC

Hi Anson, 
 
We suggest you bind the ViewModel collection to the SfListView.ItemsSource property as mentioned below. 
 
<ContentPage.BindingContext> 
    <vm:ContactsViewModel/> 
</ContentPage.BindingContext> 
 
<listView:SfListView x:Name="lstViewData" 
                        AutoFitMode="Height" 
                    ItemsSource="{Binding ContactsInfo}"> 
    <listView:SfListView.ItemTemplate > 
        <DataTemplate> 
            <ViewCell> 
                <ViewCell.View> 
                    <Label Text="{Binding ContactName}" 
                            TextColor="Maroon" FontSize="Medium" FontAttributes="Bold"/> 
                </ViewCell.View> 
            </ViewCell> 
        </DataTemplate> 
    </listView:SfListView.ItemTemplate> 
</listView:SfListView> 
 
You can also refer to our user guidance document to bind data to SfListView in the following link, 
 
We have attached the modified sample in the following link, 
 
Please check our sample and let us know if you need further assistance. 
Lakshmi Natarajan 
 


Loader.
Up arrow icon