Sabai Phoo
Sabai Phoo

Reputation: 378

Accessing ViewModel properties from Viewclass

enter image description hereI want to call Content page class from Android .cs Class.

I use StartActivity(new Intent(Application.Context, typeof(LoginPage)));

showing error message

"System.ArgumentException: type Parameter name: Type is not derived from a java type "

Does anyone know the solution for this? Please help me in Xamarin.Forms.

Upvotes: 1

Views: 137

Answers (2)

Arvind Chourasiya
Arvind Chourasiya

Reputation: 17482

This should be you App.xaml.cs class

public App()
{
  MainPage = new NavigationPage ( new MainPage());
}

MainActivity.cs file

public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
    private TextView setting;
    protected override void OnCreate(Bundle bundle)
    {       
         base.OnCreate(savedInstanceState);
         global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
         LoadApplication(new App());
         SetContentView(Resource.Layout.HomeScreen);
         setting = FindViewById<TextView>(Resource.Id.settingText);

        //check setting button is null or have value
        setting.Click += delegate
        {
            Xamarin.Forms.Application.Current.MainPage.Navigation.PushAsync(new LoginPage());
        };
    }
}

Use code above & debug to check if setting button have instance or is null.

Upvotes: 1

Vũ Hồng Sơn
Vũ Hồng Sơn

Reputation: 58

Replace typeof(LoginPage) with LoginPage.Class or LoginPage::Class.java (kotlin)

Upvotes: 0

Related Questions