2
I have this page (Tabbedpage) that creates two tabs:
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Operacional.Views"
x:Class="Operacional.Views.MainPage">
<TabbedPage.Children>
<NavigationPage Title="Indicadores">
<NavigationPage.Icon>
<OnPlatform x:TypeArguments="FileImageSource">
<On Platform="iOS" Value="tab_about.png"/>
</OnPlatform>
</NavigationPage.Icon>
<x:Arguments>
<views:Indicadores />
</x:Arguments>
</NavigationPage>
<NavigationPage Title="Paineis">
<NavigationPage.Icon>
<OnPlatform x:TypeArguments="FileImageSource">
<On Platform="iOS" Value="tab_feed.png"/>
</OnPlatform>
</NavigationPage.Icon>
<x:Arguments>
<views:PaineisPage />
</x:Arguments>
</NavigationPage>
</TabbedPage.Children>
</TabbedPage>
The thing is, I’m not getting to qualify NavigationBar
or at least create a panel above tabpages
. The ideal would be to enable the NavigationBar
, this would be ideal for me. How it works. When opening the App
, it lands on a login screen. When you log in, then you enter the MainPage
and in it the TabPages
. If I try to exeibiate the NavigationBar
does not give any error, but does not display. Or she is Hide or the TabPages
are "killing" her. Below my codes.
Mainpage
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainPage : TabbedPage
{
public MainPage ()
{
InitializeComponent ();
NavigationPage.SetHasNavigationBar(this, true);
}
}
the login screen
public void Login_Clicked(object sender, EventArgs e)
{
LoginService svc = new LoginService();
LoginRS res = svc.Login(txtUsuario.Text, txtSenha.Text);
if (res != null && res.Success )
{
App.LooggedUser = res;
Application.Current.MainPage = new MainPage();
}
else if(res != null && ! res.Success)
{
lblErroLogin.Text = res.Exception;
}
else
{
lblErroLogin.Text = "Não foi possível realizar o Login, por favor verifique sua conexão com a Internet";
}
}
and my App.xaml.Cs
public App()
{
InitializeComponent();
if (!IsUserLoggedIn)
{
MainPage = new NavigationPage(new LoginPage());
}
else
{
MainPage = new NavigationPage(new MainPage());
}
}
Diego, thanks for the explanation. I will test and put the result. The advantage here, is that despite being Forms, this project will run only on Android, Ufa!!
– pnet
Diego, just one question, how do I make Navigationbar backgroundcolor different color? I’m trying on Mainpage and it’s giving error. How do I do?
– pnet
@pnet, do you mind posting this as another question? This is a common point of doubt in the community and I think it would be easier for others to find the answer if the question is dedicated exclusively to this. (y) Thanks!
– Diego Rafael Souza
Yes, of course, actually it’s another question. Sorry. I’ll open another thread.
– pnet