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

Tap gesture recognizer in a looped grid possible?

$
0
0

Im stuck with how to make every grid unique when adding tap gesture recognizer! Is there another way to do it?

foreach (var item in list)
{
var grid = new Grid
{
BackgroundColor = Color.White,
Padding = 2,
HeightRequest = 150,
TranslationY = 5
};

        grid.Children.Add(new Label
        {
           Text = item.Title,
           FontSize = 16,
           FontFamily="Arial",
           TextColor = Color.Red,
           VerticalTextAlignment = TextAlignment.Center,
           HorizontalTextAlignment = TextAlignment.Center,
           HorizontalOptions =LayoutOptions.Center,


        });
        grid.Children.Add(new Label
        {
           Text = item.PublishTime.ToString(),
           FontSize = 10,
            FontFamily = "Arial",
            TextColor = Color.Red,
           VerticalTextAlignment = TextAlignment.Start,
           HorizontalTextAlignment = TextAlignment.End,
            TranslationX = -15,

        });
            grid.Children.Add(new Label
            {
                Text = item.Price.ToString() + " SEK",
                FontSize = 16,
                FontFamily = "Arial",
                TextColor = Color.Red,
                VerticalTextAlignment = TextAlignment.Center,
                HorizontalTextAlignment = TextAlignment.End,
                TranslationX = -15,
                WidthRequest = 90,

            });
            grid.Children.Add(new Image
            {
                Source = "item.jpg", 
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions = LayoutOptions.Center,
                WidthRequest = 120,
                HeightRequest = 120,

``
});
PostList.Children.Add(grid);


Viewing all articles
Browse latest Browse all 91519

Trending Articles



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