listview in runtime with itemtapped event and inner a tabbedpage

SaturnSaturn USMember

Hi. I'm creating a app that download a json of categorias and eventos (each categorias has several eventos). I have a foreach tha create a new tab in my tabbedpage for each categorias and create a listview with several eventos (how you will see in code below). But... for each listview created I need the itemtapped where I will navigate to another page to show the details of eventos. How I put this?!

public partial class MainPage2 : TabbedPage
{
public MainPage2()
{
InitializeComponent();

        downloadJSon();
    }       

    public async void downloadJSon()
    {
        using (var httpClient = new System.Net.Http.HttpClient())
        {
            string doc = await httpClient.GetStringAsync("http://?????????.azurewebsites.net/???/????/????????/getAll");

            var aux = JsonConvert.DeserializeObject<ObservableCollection<Eventos>>(doc);

            var eventoDataTemplate = new DataTemplate(() =>
            {
                AbsoluteLayout peakLayout = new AbsoluteLayout     {
                    HeightRequest = 250,    BackgroundColor = Color.Black,
                    VerticalOptions = LayoutOptions.Fill,         HorizontalOptions = LayoutOptions.StartAndExpand
                };

                var TituloLabel = new Label  {
                    FontSize = 30,  FontFamily = Device.OnPlatform( iOS: "MarkerFelt-Thin",
                                        Android: "Droid Sans",
                                        WinPhone: "Comic Sans MS"), TextColor = Color.White
                };

                var DescricaoLabel = new Label    {
                    TextColor = Color.FromHex("#ddd"),
                    FontFamily = Device.OnPlatform(
                                        iOS: "MarkerFelt-Thin",
                                        Android: "Droid Sans",
                                        WinPhone: "Comic Sans MS"),
                };

                var FotoImage = new Image()     { Aspect = Aspect.AspectFill    };
                var overlay = new BoxView()    {     Color = Color.Black.MultiplyAlpha(.7f)  };

                TituloLabel.SetBinding(Label.TextProperty, "Titulo");
                DescricaoLabel.SetBinding(Label.TextProperty, "DescricaoReduzida");
                FotoImage.SetBinding(Image.SourceProperty, "FotoUrl");

                peakLayout.Children.Add(FotoImage);
                peakLayout.Children.Add(overlay);
                peakLayout.Children.Add(TituloLabel);
                peakLayout.Children.Add(DescricaoLabel);

                return new ViewCell { View = peakLayout };
            });

            ObservableCollection<Categorias> listaCategorias = new ObservableCollection<Categorias>();
            foreach (var item in aux)
            {

                int i = listaCategorias.Count(c => c.CategoriaId == item.CategoriaId);
                if (i == 0)
                {
                    listaCategorias.Add(new Categorias { CategoriaId = item.CategoriaId, Categoria_Descricao = item.Categoria_Descricao });

                    this.Children.Add(new ContentPage
                    {
                        Title = item.Categoria_Descricao,

                        Content = new ListView()
                        {
                            ItemsSource = new ObservableCollection<Eventos>(aux.Where(l => l.CategoriaId == item.CategoriaId).ToList()),
                            ItemTemplate = eventoDataTemplate,
                            SeparatorVisibility = SeparatorVisibility.Default,
                            HasUnevenRows = true       
                        }

(here.. I've try put ".ItemTapped+=Itemtapped_MainPage2" but occurs a error...
});

                }
            }

        }


}


}

Tk's for help````

Sign In or Register to comment.