My application does not give an error, but nothing appears on the screen (xamarin)

0

Developing and learning xamarin. I took an example of Macoratti and decided to implement, because it is consumption of REST with xamarin. I did everything as it is on the author's website and when I squeeze, nothing appears on my smartphone (samsung J5). When I leave the first StackLayout which is a label, it appears. But the other StackLayout shows nothing. Inside the first stack, I put a Entry component together with the label, it appeared, but the placeholder was cut in half horizontally, ie only the bottom half appeared. I put below my code: MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:Teste2"
             x:Class="Teste2.MainPage">

    <StackLayout Orientation="Vertical">
        <StackLayout Padding="5,5,0,0">
            <Label Text="Adicionar um Produto" TextColor="Green" />
        </StackLayout>
        <StackLayout Padding="10,0,10,0">
            <Entry x:Name="txtNome" Placeholder="Nome do produto" HorizontalOptions="Start" 
                    VerticalOptions="StartAndExpand" HeightRequest="30" WidthRequest="300" FontSize="Small"/>
            <Entry x:Name="txtCategoria" Placeholder="Categoria do produto" HorizontalOptions="Start" 
                    VerticalOptions="StartAndExpand" HeightRequest="30" WidthRequest="300" FontSize="Small" />
            <Entry x:Name="txtPreco" Placeholder="Preço do produto" HorizontalOptions="Start" VerticalOptions="StartAndExpand" 
                    HeightRequest="30" WidthRequest="300" FontSize="Small" />
            <Button HorizontalOptions="FillAndExpand" VerticalOptions="StartAndExpand" HeightRequest="40" Text="Adicionar/Atualizar Produto" 
                    Clicked="btnAdicionar_Clicked" FontSize="Small"/>
        </StackLayout>

        <!--<StackLayout Orientation="Vertical" Padding="10,5,10,0">
            <ListView x:Name="listaProdutos" ItemSelected="listaProdutos_ItemSelected" BackgroundColor="Aqua" SeparatorColor="Blue">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <ViewCell.ContextActions>
                                <MenuItem Clicked="OnAtualizar" CommandParameter="{Binding .}" Text="Atualizar" />
                                <MenuItem Clicked="OnDeletar" CommandParameter="{Binding .}" Text="Deletar" IsDestructive="True" />
                            </ViewCell.ContextActions>
                            <StackLayout Padding="10,10" Orientation="Horizontal">
                                <Label Text="{Binding Nome}" HorizontalOptions="StartAndExpand"/>
                                <Label Text="{Binding Categoria}" TextColor="Blue" HorizontalOptions="Center"/>
                                <Label Text="{Binding Preco}" HorizontalOptions="End"/>
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </StackLayout>-->
    </StackLayout>

</ContentPage>

MainPage.xaml.cs

public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }
    }

App.cs

public partial class App : Application
    {
        public App()
        {
            InitializeComponent();

            //MainPage = new Teste2.MainPage();
            MainPage = new NavigationPage(new Teste2.MainPage());
        }

        protected override void OnStart()
        {
            // Handle when your app starts
        }

        protected override void OnSleep()
        {
            // Handle when your app sleeps
        }

        protected override void OnResume()
        {
            // Handle when your app resumes
        }
    }

EDIT1 I did this and I can see my Entry, but what I write or the placeholder is cut in half, that is, I only read the bottom. I can not read the whole text. What can this be? However, if you create more than StackLayout , there does not appear anything in the App. It seems that you are not accepting% nested%.

StackLayout Padding="10,0,10,0">
            <!--<Label Text="Adicionar um Produto" TextColor="Green" />-->
                <Entry x:Name="txtNome" Placeholder="Nome do produto" HorizontalOptions="Start" 
                    VerticalOptions="StartAndExpand" HeightRequest="30" WidthRequest="300" FontSize="Small"/>
            <Entry x:Name="txtCategoria" Placeholder="Categoria do produto" HorizontalOptions="Start" 
                    VerticalOptions="StartAndExpand" HeightRequest="30" WidthRequest="300" FontSize="Small" />
        </StackLayout>
    
asked by anonymous 29.08.2017 / 00:37

1 answer

0

The issue has been resolved. What was fogging up was that both the button and the ListView had click events and these events were only declared. Removing the event declaration in MainPage.xaml works, but I can not call an event that way, but that's for another post.

    
29.08.2017 / 20:54