Is this a bug in MonoTouch GC?

This is an unfortunate side-effect of MonoTouch (who is garbage collected) having to live in a reference counted world (ObjectiveC). There are a few pieces of information required to be able to understand what’s going on: For every managed object (derived from NSObject), there is a corresponding native object. For custom managed classes (derived from … Read more

GridLayoutManager – how to auto fit columns?

You can calculate available number of columns, given a desired column width, and load the image as calculated. Define a static funtion to calculate as: public class Utility { public static int calculateNoOfColumns(Context context, float columnWidthDp) { // For example columnWidthdp=180 DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); float screenWidthDp = displayMetrics.widthPixels / displayMetrics.density; int noOfColumns = (int) … Read more

Accessing directly a Sql Server Database in Xamarin.Forms

You cannot access directly an sql server from your pcl project in Xamarin.Forms because System.Data.SqlClient is not available on pcl. But you can do it through a dependency service. First in you PCL project declare you service public interface IDbDataFetcher { string GetData(string conn); } Then on you Android project implement the service interface [assembly: … Read more

How to view PDF file using Xamarin Forms

Android: public void OpenPdf(string filePath) { Android.Net.Uri uri = Android.Net.Uri.Parse(“file:///” + filePath); Intent intent = new Intent(Intent.ActionView); intent.SetDataAndType(uri, “application/pdf”); intent.SetFlags(ActivityFlags.ClearWhenTaskReset | ActivityFlags.NewTask); try { Xamarin.Forms.Forms.Context.StartActivity(intent); } catch (Exception) { Toast.MakeText(Xamarin.Forms.Forms.Context, “No Application Available to View PDF”, ToastLength.Short).Show(); } } iOS, a bit more complex and requiries some extra classes: public void OpenPDF(string filePath) { FileInfo … Read more

Xamarin – How to update Mono.Android version to resolve dependencies?

tried changing my target android version to 8.1 You need to change the Target Framework that is used to compile your android application, not the Target Android version (but assumably you would set these two to the same, read the Understanding Android API Levels link below. Visual Studio for Windows: Visual Studio for Mac: Target … Read more