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

how to reach Item when switch toggled inside Listview

$
0
0

I want to store item name(c_name) when toggle the switch on this row name but i can't do this anybody help me....

    <StackLayout IsVisible="False" x:Name="ShortCatagory" BackgroundColor="White" HeightRequest="100"
                      WidthRequest="160" Margin="5,5">
                    <ListView x:Name="onCategory" 
                        RowHeight="40">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <ViewCell>
                                    <StackLayout Orientation="Horizontal" Padding="2">
                                    <Switch VerticalOptions="EndAndExpand" 
                                            HorizontalOptions="EndAndExpand"
                                            x:Name="{Binding c_name}"
                                            Toggled="BestDis"
                                            IsToggled="{Binding .}"
                                            Scale=".60"/>
                                    <Label Text="{Binding c_name}"/>

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

async private void onCatagory(object sender, EventArgs args)
    {
        this.IsBusy = true;
        try
        {
            string link = "product-category";
            var data = new Services.DataSource();
            var getData = await data.DataWithoutToken(link);
            var view = JsonConvert.DeserializeObject<ObservableCollection<CategoryModel>>(getData);
            onCategory.ItemsSource = view;

            this.IsBusy = false;
        }
        catch (Exception ex)
        {
            await DisplayAlert("Error", ex.Message, "Close");
        }
        ShortCatagory.IsVisible = true;
    }

Viewing all articles
Browse latest Browse all 91519

Trending Articles



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