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

Switch IsToggled

$
0
0

hi

            <CollectionView.ItemsLayout>
                <GridItemsLayout Orientation="Vertical" Span="1" 
                                     VerticalItemSpacing="{OnIdiom 5, Phone=5, Tablet=10, Desktop=10}" 
                                     HorizontalItemSpacing="{OnIdiom 5, Phone=5, Tablet=10, Desktop=10}" />
            </CollectionView.ItemsLayout>

            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <Frame BorderColor="Gray" CornerRadius="5" IsClippedToBounds="True" 
                                               HorizontalOptions="{OnIdiom StartAndExpand, Phone=StartAndExpand, Tablet=CenterAndExpand, Desktop=CenterAndExpand}" 
                                               VerticalOptions="{OnIdiom StartAndExpand, Phone=StartAndExpand, Tablet=CenterAndExpand, Desktop=CenterAndExpand}"
                                               HasShadow="False" Padding="0" Margin="0,0,6,0">

                        <Grid ColumnSpacing="0" RowSpacing="0" HorizontalOptions="StartAndExpand" Margin="5">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto"/>
                                <RowDefinition Height="auto"/>
                            </Grid.RowDefinitions>

                            <Label Grid.Row="0" Grid.Column="0" Text="{Binding TotalAdress}" Margin="0" FontSize="14" HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand"/>


                            <Grid Grid.Row="1" Grid.Column="0" HorizontalOptions="EndAndExpand" VerticalOptions="EndAndExpand" Margin="5">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="auto"/>
                                </Grid.RowDefinitions>

                                <Switch ClassId="{Binding Id}" IsToggled="{Binding IsActive, Mode=TwoWay}" Toggled="Switch_Toggled" />

                            </Grid>
                        </Grid>
                    </Frame>
                </DataTemplate>
            </CollectionView.ItemTemplate>

            <CollectionView.EmptyView>
                <Label Text="موردی یافت نشد" HorizontalOptions="Center" FontSize="Medium" />
            </CollectionView.EmptyView>

        </CollectionView>

Why at the time page loaded call method Switch_Toggled ?

private async void Switch_Toggled(object sender, ToggledEventArgs e)
{
try
{
Switch es = sender as Switch;

            if (es.IsToggled)
            {
                var Ret = await BLL.OnAdressMobile(decimal.Parse(es.ClassId));

                await DisplayAlert(Ret.Title, Ret.Body, "تایید");
            }
            else
            {
                var Ret = await BLL.OffAdressMobile(decimal.Parse(es.ClassId));

                await DisplayAlert(Ret.Title, Ret.Body, "تایید");
            }
        }
        catch (Exception ex)
        {

        }
    }

Viewing all articles
Browse latest Browse all 204402

Trending Articles



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