Xamarin.Forms: Forms.Context is obsolete

I was having the same issue with several Dependency Services The simplest solution In a lot of cases for Single Activity Applications Xamarin.Forms.Forms.Context Can be replaced with Android.App.Application.Context The Background in more detail Android.App.Application.Context returns the global Application Context of the current process tied to the lifecycle of the Application, as apposed to an Activity … Read more

Xamarin.Forms – How to overlay an ActivityIndicator in the middle of a StackLayout programmatically

If you have problems with RelativeLayout, you can also use AbsoluteLayout which works in a similar context. Sample code below: var overlay = new AbsoluteLayout(); var content = new StackLayout(); var loadingIndicator = new ActivityIndicator(); AbsoluteLayout.SetLayoutFlags(content, AbsoluteLayoutFlags.PositionProportional); AbsoluteLayout.SetLayoutBounds(content, new Rectangle(0f, 0f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)); AbsoluteLayout.SetLayoutFlags(loadingIndicator, AbsoluteLayoutFlags.PositionProportional); AbsoluteLayout.SetLayoutBounds(loadingIndicator, new Rectangle(0.5, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)); overlay.Children.Add(content); overlay.Children.Add(loadingIndicator); If you … Read more

Xamarin Forms Swipe Left/Swipe Right Gestures

No need third party libraries.. No need to pay.. Just add these two classes & Implement your swipe listeners Step 1: Copy paste these two classes SwipeListener.cs using System; using Xamarin.Forms; namespace SwipeLib { public class SwipeListener : PanGestureRecognizer { private ISwipeCallBack mISwipeCallback; private double translatedX = 0, translatedY = 0; public SwipeListener(View view, ISwipeCallBack … Read more

Xamarin.Forms – Change StatusBar Color

I believe you would be better off writing a little bit of platform-specific code: For Android: On your MainActivity.cs on the Droid project, right after LoadApplication(new App()); of the overriden OnCreate method, add: Window.SetStatusBarColor(Android.Graphics.Color.Argb(255, 0, 0, 0)); Like so: protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); LoadApplication(new … Read more

Camera access with Xamarin.Forms

I finally created a minimum solution for iOS and Android. The shared project First, let’s look into the shared code. For an easy interaction between the shared App class and the platform-specific code we store a static Instance within the public static App: public static App Instance; Furthermore, we will display an Image, which will … Read more

How to correctly use the Image Source property with Xamarin.Forms?

You shouldn’t reference the path because the source property is cross-platform and since every platform has a different folder for assets like images, you only need to specify the filename and extension. The Image class knows where to look to find the file. Image files can be added to each application project and referenced from … Read more

The “XamlCTask” task failed unexpectedly on visual studio for xamarin

This issue arise, if your Xamarin.Form version is not compatible/matching with your NuGet package which you have installed. So, I have just updated Xamarin.Forms for both xx.Droid and PCL and make the match the dependencies with NuGet package. Now it is working fine. Hope so this will work for you.

Release build but debugging enabled

I’m using Visual Studio for Mac and came across this same “Archive built with debugging enabled” warning after creating an archive of the Android project. To fix this, do the following: Go into the Android project options (double-click on the Android project). Select the Compiler options. In the “Debug information” drop-down menu, select None (mine … Read more