Forum Xamarin.Forms

Sequence contains no matching element at System.Linq.Enumerable.Last<Xamarin.Forms.Page>

I want to use only Main.axml in my project.

protected override void OnCreate (Bundle bundle)
{
    base.OnCreate (bundle);
    global::Xamarin.Forms.Forms.Init (this, bundle);
    LoadApplication (new App ());
    SetContentView(Resource.Layout.Main);
    AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironmentUnhandledExceptionRaiser;
}

private void AndroidEnvironmentUnhandledExceptionRaiser(object sender, RaiseThrowableEventArgs e)
{
    string str = e.Exception.ToString();
}

I press 'Escape' ('Back') button and have this exception:

e.Exception { System.InvalidOperationException: Sequence contains no matching element at System.Linq.Enumerable.Last (System.Collections.Generic.IEnumerable1<Xamarin.Forms.Page>,System.Func2,System.Linq.Enumerable/Fallback) <0x00364> at System.Linq.Enumerable.Last (System.Collections.Generic.IEnumerable`1) <0x0028b> at Xamarin.Forms.Platform.Android.Platform.HandleBackPressed (object,System.EventArgs) at Xamarin.Forms.Platform.Android.FormsApplicationActivity.OnBackPressed () at Android.App.Activity.n_OnBackPressed (intptr,intptr) [0x00009] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Android.App.Activity.cs:1987 at (wrapper dynamic-method) object.56117541-8b13-4e27-96fb-c2b57f6bfd8a (intptr,intptr) } System.InvalidOperationException

Answers

  • mac121mac121 Member ✭✭✭

    Hi all,

    Any solutions for this issue..?

  • 15mgm1515mgm15 USMember ✭✭✭✭

    @mac121 Did you found the solution for this?

  • JoeMankeJoeManke USMember ✭✭✭✭✭

    If you're calling SetContentView() in a Forms app, you're doing something terribly wrong. Once you call LoadApplication() you should not be touching the UI directly from your Activity at all.

Sign In or Register to comment.