Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to bind the `count` queried from a database to a `footer` inside `ListView` in Xamarin Forms.

$
0
0
<ListView  x:Name="listView">
        <ListView.Footer>
            <StackLayout>
                <Label Text="{Binding Count}" BackgroundColor="Gray"></Label>
            </StackLayout>
        </ListView.Footer>
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="2*"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="2*"/>
                        </Grid.ColumnDefinitions>
                        <Image Source="{Binding image}" WidthRequest="50" HeightRequest="50" Grid.Column="0" VerticalOptions="Center"/>
                        <StackLayout Grid.Column="1">
                            <Label Text="{Binding FullName}" TextColor="#f35e20" HorizontalTextAlignment="Center"/>
                        </StackLayout>
                        <StackLayout Grid.Column="2">
                            <Label Text="{Binding SoccerStatus}" HorizontalTextAlignment="Center" TextColor="#503026"/>
                        </StackLayout>
                        <StackLayout Grid.Column="3">
                            <Label Text="{Binding CurrentDate}" HorizontalTextAlignment="Center" TextColor="#503026"/>
                        </StackLayout>
                    </Grid>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>

    </ListView>

public void DisplayCount()
{
      var datetoday = DateTime.Now.ToString("ddMMyyyy");
      var count_in = (from x in conn.Table<SoccerAvailability>().Where(x => string.Equals(x.SoccerStatus, "IN", StringComparison.OrdinalIgnoreCase) && x.CurrentDate == datetoday) select x).Count();

 }

Viewing all articles
Browse latest Browse all 77050

Trending Articles



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