I'm having trouble showing the content of the pages. I created a ListView with some options, follow the code below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace testeVale.Views
{
public class Menu
{
public string itemMenu { get; set; }
}
public partial class MainPage : ContentPage
{
public List<Menu> Itens { get; set; }
public MainPage()
{
InitializeComponent();
this.Itens = new List<Menu>
{
new Menu { itemMenu = "Sobre Nós"},
new Menu { itemMenu = "Cidades" },
new Menu { itemMenu = "Eventos" },
new Menu { itemMenu = "Contato" }
};
this.BindingContext = this;
}
void ListViewMenu_ItemTapped(object sender, ItemTappedEventArgs e)
{
var menu = (Menu) e.Item;
if (menu.itemMenu is "Sobre Nós")
{
Navigation.PushAsync(new sobreNos(menu));
}
if (menu.itemMenu is "Contato")
{
Navigation.PushAsync(new contato(menu));
}
/*DisplayAlert("Menu", string.Format("Você tocou no modelo'{0}'", menu.itemMenu),"Fechar");*/
}
}
}
On the "About Us" page for example, I'm trying to display the content but it's only showing the 'back' button
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace testeVale.Views
{
public partial class sobreNos : ContentPage
{
public sobreNos(Menu opcao)
{
InitializeComponent();
this.Title = opcao.itemMenu;
var label = new Label { Text = "This is a label." };
}
private void buttonVoltar_Clicked(object sender, EventArgs e)
{
Navigation.PushAsync(new MainPage());
}
}
}
I've also tried 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"
x:Class="testeVale.Views.sobreNos">
<ContentPage.Content>
<StackLayout Padding="5,10">
<Label TextColor="#77d065" FontSize = "20" Text="Sobre Nós" />
</StackLayout>
</ContentPage.Content>
<Button x:Name="buttonVoltar" Text="Voltar" Clicked="buttonVoltar_Clicked" VerticalOptions="End"></Button>
</ContentPage>
Nothing appears, just the button, what am I doing wrong?