When using OnBackButton in navigation it behaves weirdly to work correctly I have to keep wrapping it inside of WhileActive when it comes to navigation pages. What happens is without the WhileActive if I set a OnBackButton inside a page, and then inside that page I have another page with OnBackButton both are triggered. (Which I believe is never the wanted behavior):
<SomeNavigation />
<Page ux:Name="page1">
<OnBackButton ux:Name="back1" />
<Page ux:Name="subpage1">
<OnBackButton ux:Name="back2" />
</Page>
</Page>
<Page></Page>
If I’m inside of subpage1 and press the back button both back2 and back1 are triggered, I don’t think that’s ever the wanted effect, so perhaps that can be fixed somehow. I can’t think of a situation where that’s wanted, but perhaps it is.
So for now I wrap each of them inside of WhileActive:
<SomeNavigation />
<Page ux:Name="page1">
<WhileActive>
<OnBackButton ux:Name="back1" />
</WhileActive>
<Page ux:Name="subpage1">
<WhileActive>
<OnBackButton ux:Name="back2" />
</WhileActive>
</Page>
</Page>
<Page></Page>
If there is a situation where the current behavior is wanted hopefully someone can show me that example, and if so please add a property to OnBackButton that can make this easier. I prefer not to mess with IsEnabled property because its just easier to then just wrap with WhileActive