Hello! For PageControl there’s ActiveIndex in order to get the current page in view (via Observable), but how can this be done with Navigator? In the example below I could get the current page by using a global string variable and changing it in router.push (or Activated for every page) and OnGoBack, but that’s more work than simply getting it straight from the UX via Observable for example.
<App>
<JavaScript>
module.exports = {
gotoGreenPage: function() {router.push("greenPage");},
gotoRedPage: function() {router.push("redPage");},
logCurrentPath: function() {
console.log("Current path: ?");
}
};
</JavaScript>
<Router ux:Name="router" />
<Navigator ux:Name="navigator" DefaultPath="yellowPage">
<Page ux:Name="yellowPage" Background="Yellow">
<Button Text="Goto green page" Background="Black" Width="200" Height="100" Alignment="Center" Y="-25%" Clicked="{gotoGreenPage}" />
<Button Text="Log current path" Background="Black" Width="200" Height="100" Alignment="Center" Clicked="{logCurrentPath}" />
<Button Text="Goto red page" Background="Black" Width="200" Height="100" Alignment="Center" Y="25%" Clicked="{gotoRedPage}" />
</Page>
<Page ux:Name="greenPage" Background="Green">
<Button Text="Log current path" Background="Black" Width="200" Height="100" Alignment="Center" Clicked="{logCurrentPath}" />
</Page>
<Page ux:Name="redPage" Background="Red">
<Button Text="Log current path" Background="Black" Width="200" Height="100" Alignment="Center" Clicked="{logCurrentPath}" />
</Page>
</Navigator>
</App>