List View Didn't load correctly

i'm using ...
VS 2017 version 15.8.6 ;
Xamarin.Forms 3.3.0.871608
syncfusionListView ...


when we load sfListview ... we had to set height manually
if we don't ... its a fill more than height of parent and items didn't apear


screen shots


Xaml Code ...
<?xml version="1.0" encoding="utf-8" ?>

<ContentPage.Content>


<Grid.RowDefinitions>


</Grid.RowDefinitions>

            <StackLayout Grid.Row="1" Padding="20" Spacing="10" VerticalOptions="StartAndExpand" HorizontalOptions="FillAndExpand">

                <Controls:CustomLabel TextColor="#660000" Text="{Binding ValidationMessage}" IsVisible="{Binding HasErrors}"
                                      HorizontalOptions="FillAndExpand"
                                          HorizontalTextAlignment="Center" 
                                       LineBreakMode="CharacterWrap" MaxLines="50"/>

                <StackLayout>
                    <Controls:CustomLabel x:Name="lbRemoveAll" Text="{Resx:TranslateExtension Text=lbSetCartEmpty}"  Style="{StaticResource lbLinkButton}">
                        <Controls:CustomLabel.GestureRecognizers>
                            <TapGestureRecognizer Tapped="RmoveAllItems_Tapped"/>
                        </Controls:CustomLabel.GestureRecognizers>
                    </Controls:CustomLabel>

                </StackLayout>

                <StackLayout>
                    <sfListView:SfListView 
                        Grid.Row="1"
                        x:Name="lvItems"
                        AllowSwiping="True"
                        ItemsSource="{Binding TbCartItems}"
                        SelectionBackgroundColor="Transparent"
                        ItemSpacing="10"
                        AutoFitMode="Height"
                        LoadMoreOption="None"
                        IsScrollBarVisible="False"
                        FlowDirection="LeftToRight"
                        Orientation="Vertical"
                        ItemSize="100" >

                        <sfListView:SfListView.ItemTemplate>
                            <DataTemplate>
                                <Frame HasShadow="True" BackgroundColor="White" Padding="5"
                                  FlowDirection="{Binding Source={x:Static Helpers:Settings.dFlowdirection}}">

                                    <Controls:CustomLabel Text="Ahmad Azim"/>


                                </Frame>
                            </DataTemplate>
                        </sfListView:SfListView.ItemTemplate>
                    </sfListView:SfListView>

                </StackLayout>

                <StackLayout x:Name="slTotal">
                    <Controls:CustomLabel   Text="{Resx:TranslateExtension Text=lbItemsTotal}" HorizontalTextAlignment="Center"/>
                    <Controls:CustomLabel   Text="{Binding Total}" HorizontalTextAlignment="Center"
                                                TextColor="{DynamicResource BaseColor}"/>
                </StackLayout>

                <Controls:CustomeButton x:Name="btnContinuePay"
                                                Text="{Resx:TranslateExtension Text=btnContinuePay}"                                                                                                     
                                                Command="{Binding ContinuePay}"/>
            </StackLayout>
        </Grid>
    </ScrollView>
</ContentPage.Content>


cs Code
using ALOROUBAH.Controls;
using ALOROUBAH.Helpers;
using ALOROUBAH.Resources;
using ALOROUBAH.ViewModel;
using System;
using Xamarin.Forms.Xaml;

namespace ALOROUBAH.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CartPage : CustomPage
{
#region Functions
public CartPage()
{
InitializeComponent();
cToolBar.ShowCart(false);
}

    private void CheckCartItems()
    {
        if (Settings.lstCartItems.Count == 0)
        {
            lbRemoveAll.Text = AppResources.lbCartIsEmpty;
            btnContinuePay.IsVisible = slTotal.IsVisible = false;
        }
        else
        {
            lbRemoveAll.Text = AppResources.lbSetCartEmpty;
            btnContinuePay.IsVisible = slTotal.IsVisible = true;
        }
    }
    #endregion
    #region Events
    async void RmoveAllItems_Tapped(object sender, EventArgs e)
    {
        try
        {
            var vm = (CartViewModel)this.BindingContext;
            await vm.OnRemoveAllItems();
            //lvItems.ItemsSource = vm.lstClsCartItems;
            CheckCartItems();
        }
        catch (Exception ex)
        {
            Log.Report(ex);
        }
    }
    #endregion
}

}

Tagged:

Posts

  • igorkr_10igorkr_10 Member ✭✭✭
    edited October 2018
    Try to create Grid. In main grid create one row with height="*". Listview create exactly in this row. Then create one more grid in main grid with with two rows. First row set height="70*", second height="30*". Stacklayout with controls set to second row.
  • thank you @igorkr_10
    done ^_^

Sign In or Register to comment.