0

I am new to Xamarin. So the problem is when I open my tabs it opens the first one i.e "Schedule_FRI". But I want to open "Schedule_SAT" when I open the tab pages. Is this possible and how do I do that?

<?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:local="clr-namespace:App4.Pages;assembly=App4"
            xmlns:i8ln="clr-namespace:App4;assembly=App4"
            x:Class="App4.Pages.Schedule" Title="{i8ln:Translate PageName_Schedule}">

  <local:Schedule_FRI Title="{i8ln:Translate FRI}"/>
  <local:Schedule_SAT Title="{i8ln:Translate SAT}"/>
  <local:Schedule_SUN Title="{i8ln:Translate SUN}"/>

  <local:Schedule_Lajna Title="{i8ln:Translate Schedule_Lajna}"/>


</TabbedPage>
476rick
  • 2,764
  • 4
  • 29
  • 49
  • Can u show the detail code of your reference?( Local:Schedule_FRI,SAT and i8ln.) The whole project should be better. – Mike Ma Nov 21 '16 at 09:40

2 Answers2

1

When you navigate to the page after creating the instance of the Tab page

for example:

            var page = new App4.Pages.Schedule();

You need to set current page (the tab that you want to be active).

[Hint Array indexes start from 0 ;) if you want second tab to be active put 1 in Children Array]

            page.CurrentPage = page.Children[{{INT TAB PAGE INDEX HERE}}];

and in the end set the Tabbed Page as MainPage

            Application.Current.MainPage = new MainPage(page);
Ljupcho Hristov
  • 255
  • 3
  • 5
0

I don't think you can set this in the XAML, but you can set this in code using the CurrentPage property, e.g. in a page load event handler. Add an x:Name attribute to your tab pages to allow them to be easily referenced in code, e.g. x:name="satSchedulePage", and then you'll be able to put this.CurrentPage = this.satSchedulePage; within the TabbedPage code.

Ben Jackson
  • 1,108
  • 6
  • 9