How to call a specific platform page from xamarin.forms

I am new to developing applications for xamarin, I have a few questions:

  • Is it possible to call a specific platform page from the Xamarin.Form page?
  • Can I navigate pages from a view model?

Let me explain clearly.

I have an XFView.xaml , XFView.xaml.cs and XFViewModel.cs in a PCL project (Xamarin.Forms) from XFView.xaml.cs or XFViewModel.cs I want to call the MAActivity.cs page, which is present in the Xamarin.Andriod project

I tried a lot, but had no idea.

+6
source share
1 answer

Whenever you want to call something from native ( MAActivity.cs in your case), you should use DependencyService.

For instance:

  • Dependency Service Configuration

     // PCL Project public interface INativePages { void StartMA(); } // MonoDroid Project [assembly: Dependency(typeof(NativePages))] public class NativePages : INativePages { public void StartMA() { var intent = new Intent(Forms.Context, typeof(MAActivity)); Forms.Context.StartActivity(intent); } } 
  • PCL call

     // PCL Project DependencyService.Get<INativePages>().StartMA(); 
+7
source

Source: https://habr.com/ru/post/982920/


All Articles