Button does not appear in App

-1

I made a button, listview. The listview is working because I started it, but how do I do it with the button? Below my code:

protected override async void OnAppearing()
        {
            base.OnAppearing();

            //Task.Run(async () => await CarregaDados(IdOrcamento)).GetAwaiter().GetResult();
            await CarregaDados(IdOrcamento);

            Entry ent = new Entry
            {
                Placeholder = "Motivo"
            };


            Button btnOk = new Button
            {
                Text = "Aprovar",
                BackgroundColor = Color.Gold,
                Font = Font.Default,
                FontSize = 10,
                TextColor = Color.Green,
                HeightRequest = 35,
                WidthRequest = 80
            };

            Button btnCancel = new Button
            {
                Text = "Negar",
                BackgroundColor = Color.Gold,
                Font = Font.Default,
                FontSize = 10,
                TextColor = Color.Green,
                HeightRequest = 35,
                WidthRequest = 80
            };

            Button btnVoltar = new Button
            {
                Text = "Voltar",
                BackgroundColor = Color.Gold,
                Font = Font.Default,
                FontSize = 10,
                TextColor = Color.Red,
                HeightRequest = 35,
                WidthRequest = 80
            };

            btnVoltar.Clicked += Voltar;


            ListView lv = new ListView()
            {
                HasUnevenRows = true,
                SeparatorVisibility = SeparatorVisibility.Default,
                BackgroundColor = Color.White,
                SeparatorColor = Color.Gold,
                SelectedItem = "lv_ItemSelected",
                WidthRequest = 240,
                HeightRequest = 180
            };


            lv.ItemsSource = _data;

            lv.ItemTemplate = new DataTemplate(typeof(ListItemCell));
            lv.ItemTemplate.SetBinding(TextCell.TextProperty, "Produto");
            lv.ItemTemplate.SetBinding(TextCell.DetailProperty, "DadosItens");

            this.Content = lv;

        }

        private static void Voltar(object sender, EventArgs e)
        {

        }
    
asked by anonymous 14.09.2017 / 13:21

1 answer

0

I have resolved. In OnAppearing I created a new instance of Stacklayout and put the buttons, entry, listview and returned this stacklayout. It worked. More or less this:

StackLayout stack = new StackLayout()
            {
                Children = { ent, btnOk, btnCancel, btnVoltar, lv }
            };

            this.Content = stack;
    
14.09.2017 / 13:29