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

Get checked values from Listview in Xamarin forms

$
0
0

I am new to xamarin as well as for the C#. I have a listview in my app and I am binding data through ItemsSource. I have a checkbox inside the listview. I am using Xamarin.Forms.InputKit. What I want is to access/get all checked row data via ViewModel. Data binding works well. I tried with CheckChangedCommand, but it is not triggering inside the ViewModel.

ListView....

<ListView ItemsSource="{Binding LifeDemandList}" x:Name="lDemandView" HasUnevenRows="True">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <StackLayout HeightRequest="44" IsVisible="True" BackgroundColor="White" Orientation="Vertical">

                    <Grid Padding="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"></ColumnDefinition>
                            <ColumnDefinition Width="*"></ColumnDefinition>
                            <ColumnDefinition Width="*"></ColumnDefinition>
                            <ColumnDefinition Width="40"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <StackLayout BackgroundColor="White" HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand" Grid.Column="0">
                            <Label HorizontalOptions="CenterAndExpand" FontFamily="{Binding quicksandsFont}" FontSize="14" FontAttributes="Bold" VerticalOptions="FillAndExpand" TextColor="Black" Text="{Binding DEMAND}"/>
                        </StackLayout>
                        <StackLayout BackgroundColor="White" HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand" Grid.Column="1">
                            <Label HorizontalOptions="CenterAndExpand" FontFamily="{Binding quicksandsFont}" FontSize="14" FontAttributes="Bold" VerticalOptions="FillAndExpand" TextColor="Black" Text="{Binding PREMIUM}"/>
                        </StackLayout>
                        <StackLayout BackgroundColor="White" HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand" Grid.Column="2">
                            <Label HorizontalOptions="CenterAndExpand" FontFamily="{Binding quicksandsFont}" FontSize="14" FontAttributes="Bold" VerticalOptions="FillAndExpand" TextColor="Black" Text="{Binding LATEFEE}"/>
                        </StackLayout>
                        <StackLayout BackgroundColor="White" HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand" Grid.Column="3">
                            <input:CheckBox  HorizontalOptions="CenterAndExpand" IsChecked="{Binding ROWCHECK}" Type="Check"/>
                        </StackLayout>
                    </Grid>

                </StackLayout>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

Sample data binding via ViewModel.

List<LifeDemandData> lList = new List<LifeDemandData>();

    LifeDemandData ldd = new LifeDemandData();
    ldd.DEMAND = "2019/03";
    ldd.PREMIUM = "2,000.00";
    ldd.LATEFEE = "10.00";
    ldd.ROWCHECK = false;
    lList.Add(ldd);

    LifeDemandData ldd1 = new LifeDemandData();
    ldd1.DEMAND = "2019/04";
    ldd1.PREMIUM = "11,896.00";
    ldd1.LATEFEE = ".00";
    ldd1.ROWCHECK = false;
    lList.Add(ldd1);

    LifeDemandList = lList;

Viewing all articles
Browse latest Browse all 77050

Trending Articles



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