0

While loading Listview with data the black background is showing to load every single view cell. Does anybody know to change the color or remove that style?

I have tried to load the Listview from code-behind also. Is there any way to customize this?

Refer this screenshot enter image description here

The black background happens before the view cell loading.

 <ContentPage.Content>
    <StackLayout>
        <Button Pressed="Button_Pressed" Text="Back"/>
        <ListView x:Name="MyList" BackgroundColor="LightBlue" HasUnevenRows="False">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <Grid HeightRequest="60" BackgroundColor="Bisque">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Label Grid.Column="0" Text="{Binding Name}"/>
                            <Label Grid.Column="1" Text="{Binding Quantity}"/>
                            <Label Grid.Column="2" Text="{Binding Value}"/>
                        </Grid>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackLayout>
</ContentPage.Content>

code-behind:

 public ObservableCollection<ListItemModel> listItems { get; }
    public ListViewPage2 ()
    {
        listItems = new ObservableCollection<ListItemModel>();

        listItems.Add(new ListItemModel { Name = "First", Quantity = 1, Value = "10.00" });
        listItems.Add(new ListItemModel { Name = "Secound", Quantity = 2, Value = "20.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });
        listItems.Add(new ListItemModel { Name = "Third", Quantity = 3, Value = "30.00" });

        InitializeComponent();

        MyList.ItemsSource = listItems;
    }

    private void Button_Pressed(object sender, System.EventArgs e)
    {
        Application.Current.MainPage.Navigation.PopModalAsync();
    }
Riyas
  • 475
  • 1
  • 8
  • 27

0 Answers0