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

How to pass data from Label inside ListView

$
0
0

Hi Xamarin forum how can I get my data from my Label inside my listView here is my code

XAML

<ListView  x:Name="listViewPost" RowHeight="570" Margin="0" ItemTapped="ViewPost" SeparatorVisibility="None" IsPullToRefreshEnabled="True">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <Frame Padding="10,0,10,10" WidthRequest="400">
                                    <Frame CornerRadius="4" WidthRequest="400" Padding="0,0,0,10">
                                        <StackLayout Margin="5,0,5,0" Padding="0">
                                            <StackLayout>
                                                <StackLayout Orientation="Horizontal">
                                                    <controls:CircleImage Source="default_user.jpg" Aspect="AspectFit" BorderColor="Gray" BorderThickness="1" Grid.Column="0" Grid.Row="0">
                                                        <controls:CircleImage.WidthRequest>
                                                            <OnPlatform x:TypeArguments="x:Double">
                                                                <On Platform="Android, iOS">25</On>
                                                            </OnPlatform>
                                                        </controls:CircleImage.WidthRequest>
                                                        <controls:CircleImage.HeightRequest>
                                                            <OnPlatform x:TypeArguments="x:Double">
                                                                <On Platform="Android, iOS">25</On>
                                                            </OnPlatform>
                                                        </controls:CircleImage.HeightRequest>
                                                    </controls:CircleImage>
                                                    <StackLayout Margin="0,5,0,5">
                                                        <Label Text="{Binding Uploader}" HorizontalOptions="Start" FontSize="16" x:Name="uploader"  FontAttributes="Bold" FontFamily="sans-serif-light">
                                                            <Label.GestureRecognizers>
                                                                <TapGestureRecognizer Tapped="Tap_Uploader"/>
                                                            </Label.GestureRecognizers>
                                                        </Label>
                                                        <StackLayout Orientation="Horizontal">
                                                            <Label Text="Posted on " FontFamily="sans-serif-light"/>
                                                            <Label Text="{Binding dateUpload, StringFormat='{}{0:MMM d,yyyy}'}" HorizontalOptions="Start" FontSize="12" FontFamily="sans-serif-light"/>
                                                        </StackLayout>
                                                    </StackLayout>
                                                </StackLayout>
                                            </StackLayout>
                                            <Label Text="{Binding PostContent}" FontSize="15"/>
                                            <Image WidthRequest="400" HeightRequest="400" Aspect="AspectFill" Source="{Binding Photo}"/>
                                        </StackLayout>
                                    </Frame>
                                </Frame>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>

CodeBehind

public void Tap_Uploader(object sender, EventArgs e)
{

        string valueName = uploader.Text;

    }

Viewing all articles
Browse latest Browse all 89864

Trending Articles



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