I have a list of Tabs, I use StackLayout to divide it. I don't use TabbedPage because the Tabs share the same page.
Page1.xaml
<StackLayout Padding="10,10,10,0"> <Frame x:Name="tab1" Padding="0" HasShadow="False"> <StackLayout> <Label TextColor="#848484" FontSize="13" HorizontalTextAlignment="Center" Text="Tab 1" /> <Label HeightRequest="2" Margin="0,3,0,0" HorizontalOptions="FillAndExpand" BackgroundColor="#00AA13" /> ---> BackgroundColor changes when Tapped </StackLayout> <Frame.GestureRecognizers> <TapGestureRecognizer Tapped="tab1_Tapped" /> </Frame.GestureRecognizers> </Frame> </StackLayout> <StackLayout Padding="10,10,10,0"> <Frame x:Name="tab2" Padding="0" HasShadow="False"> <StackLayout> <Label TextColor="#848484" FontSize="13" HorizontalTextAlignment="Center" Text="Tab 2" /> <Label HeightRequest="2" Margin="0,3,0,0" HorizontalOptions="FillAndExpand" BackgroundColor="#fff" /> ---> Default BackgroundColor Label </StackLayout> <Frame.GestureRecognizers> <TapGestureRecognizer Tapped="tab2_Tapped" /> </Frame.GestureRecognizers> </Frame> </StackLayout> ......
How when the tabs are Tapped can I Active the tab by changing the BackgroundColor. I tried by setting Preferences. Thanks for all the help
private void tab1_Tapped(object sender, EventArgs e)
{
var tabactive = "tab1";
ActiveColorBg();
}
private void tab2_Tapped(object sender, EventArgs e)
{
var tabactive = "tab2";
ActiveColorBg();
}
..........
private void ActiveColorBg()
{
var bgcolor = "#00AA13";
}