I am currently trying to understand how to get the name of the (xaml) page I am currently into, with my Xamarin Form app.
How am I supposed to do it? I tried a variety of cases, even looking around the Internet, but nothing actually worked for me so far :/
This is just C# reflection - the name of the XAML page should match the name of it's class
var name = this.GetType ().Name;
You would (commonly) use wither a one page app (master/detail, tabs page) or a set of navigable pages, managed by a NavigationPage.
App.Current.MainPage
would (normally) contain the first page shown and if it has .Navigation
that would be the NavigationPage that can give you the most recently shown page - last one in the stack. If it doesn't you could assume your app being one page app.
All of the above is just "common" and not necessarily true in all cases, but gives you a starting point where to look for your current page.
var actionPage = App.Current.MainPage;
if (actionPage.Navigation != null)
actionPage = actionPage.Navigation.NavigationStack.Last();
actionPage.DisplayActionSheet(...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With