Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Bug or by design? Xamarin.Forms.Forms.Context is null

YuMengYuMeng USMember

I've reported the issue in the Xamarin.Forms annoucement thread but it doesn't seem to get any attention so I am creating a new thread for it.

After upgrading to 1.1.1, Xamarin.Forms.Forms.Context gives back a null value for context1. Android.App.Application.Context still works.
var context1 = Xamarin.Forms.Forms.Context; var context2 = Android.App.Application.Context;

Before the upgrade, context1 holds the following value

context1    {DotnetCatalog.Droid.MainActivity}  DotnetCatalog.Droid.MainActivity

Posts

  • CraigDunnCraigDunn USXamarin Team Xamurai

    when are you checking the value of Forms.Context?

  • YuMengYuMeng USMember

    Before the first page is shown. My view model for the page uses dependency service to read an android asset file. Xamarin.Forms.Forms.Context.Assets used to work.

  • StephaneDelcroixStephaneDelcroix USInsider, Beta ✭✭✭✭

    since 1.1.1, Context is only set on SetPage(). This causes some issues as being unable to do a Device.BeginInvokeOnMainThread() or simply trigger property changed event on BindableObject. This is known as a problem and will be worked on.

Sign In or Register to comment.