Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

FlowListView "FlowLoadingCommand" is not being called

$
0
0

I have implemented daniel luberda's FlowListView, and am trying to make an infinite loading FlowListView. However, for some reason I cannot get the loading command to get called, and I cannot seem to figure out why.

I have an ICommand implementation:
"public ICommand LoadingCommand
{ get; private set;}"

Which is begin set in the VM's contructor
"LoadingCommand = new Command(async () =>
{
await LoadMoreAsync();
});"

And the method itself looks like this:
"private async Task LoadMoreAsync()
{
SQLiteConnection conn = new SQLiteConnection(App.DatabaseLocation);
conn.CreateTable();

        int startIndex = Products.Count;

        await Task.Delay(1000);

        for (int i = startIndex; i < startIndex + 2; i++)
        {
            try
            {
                Products.Add((ProductModel)(conn.Get(i, new TableMapping(typeof(ProductModel), CreateFlags.None))));
            }
            catch (System.InvalidOperationException)
            {
                System.Diagnostics.Debug.WriteLine("No more elements to load");
            }

        }
        conn.Close();

        flowIsLoadingInfinite = false;
    }"

My XAML page file looks like this:

"

<StackLayout>
    <Button Command="{Binding ClickedCommand}" Text="Click me to add items"/>

    <flv:FlowListView x:Name="flowListView" FlowColumnCount="2" SeparatorVisibility="None" HasUnevenRows="True"
                      BackgroundColor="Azure" FlowRowBackgroundColor="LightGray"
                      FlowTappedBackgroundColor="Red" FlowIsLoadingInfiniteEnabled="True"
                      FlowItemsSource="{Binding Products}"
                      FlowIsLoadingInfinite="{Binding FlowIsLoadingInfinite}"
                      FlowLoadingCommand="{Binding LoadingCommand}"
                      FlowTotalRecords="{Binding TotalRecords}">

        <flv:FlowListView.FlowLoadingTemplate>
            <DataTemplate>
                <ViewCell>
                    <Label
                        HorizontalTextAlignment="Center"
                        VerticalTextAlignment="Center"
                        TextColor="Black"
                        Text="Loading..."
                    ></Label>
                </ViewCell>
            </DataTemplate>
        </flv:FlowListView.FlowLoadingTemplate>

        <flv:FlowListView.FlowColumnTemplate>
            <DataTemplate>
                <Grid Padding="5">
                    <BoxView Color="White" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Row="0"/>
                    <StackLayout Padding="5" Grid.Row="0">
                        <Image Source="{Binding ProductImgUrl}" HeightRequest="120" Aspect="AspectFill" HorizontalOptions="Center" VerticalOptions="Center"/>
                        <Label Text="{Binding ProductTitle}" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" HorizontalTextAlignment="Center"/>
                        <Label Text="{Binding ProductDescription}" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"  HorizontalTextAlignment="Center"/>
                    </StackLayout>
                </Grid>
            </DataTemplate>
        </flv:FlowListView.FlowColumnTemplate>

    </flv:FlowListView>
</StackLayout>

"


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>