Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,363 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
In Xamarin Forms, How can I check the current page by name, something like this:
if (App.Current.MainPage == MyAddress)
{
/ do something
}
Thanks,
Jassim
Odds are your MainPage will not be the actual page you want, but a MasterDetailPage or NavigationPage or TabbedPage or Shell, so you need to dig a little deeper. Besides that, using the type of the page is probably the best option.
// Assuming your MainPage is a NavigationPage and MyAddress is the class name of the page you want
var navPage = Application.Current.MainPage as NavigationPage;
if (navPage?.CurrentPage is MyAddress)
{
// do something
}