I have a Xamarin Forms application with a TabbedPage that contains different Children pages. I want to be able to know which child (tab) is active from my viewmodel. So I can
The ServiceListPage.xaml looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<pages:BaseTabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:ABBI_XPlat_3.Pages;assembly=ABBI_XPlat_3"
x:Class="ABBI_XPlat_3.Pages.ServiceListPage"
SelectedItem="{Binding CurrentTab, Mode=TwoWay}"
Title="Control ABBIs">
<pages:BaseTabbedPage.ToolbarItems>
<ToolbarItem x:Name="DisconnectButton" Name="Disconnect" />
</pages:BaseTabbedPage.ToolbarItems>
<pages:BaseTabbedPage.Children>
<pages:ProfilesPage Title="Profiles" />
<pages:VolumePage Title="Volume" />
<pages:SensitivityPage Title="Sensitivity" />
<pages:RemoteCtrlPage Title="Remote Control" />
</pages:BaseTabbedPage.Children>
</pages:BaseTabbedPage>
All the children pages use the same viewmodel. Which I navigate to using mvvmcross:
ShowViewModel<ServiceListViewModel>(new MvxBundle(bundle));
I have tried to Bind the CurrentTab property in the viewmodel, but the setter never gets called when I change tabs.
How can I detect which Tab is active then?