Hello Coders,

I have updated dannycabrera.GetiOSModel to version 1.6 with Apple’s new iPad models: iPad Pro 12.9-inch (3rd generation) and iPad Pro 11-inch. Both of these new iPad Pro versions include both WiFi and WiFi + Cellular models. This little library has taken off from just a few hundred total downloads to surpassing 56k this week. Hope it continues to be helpful for all Xamarin developers.

Sometimes you need to present the user with data and wait for a response all while not lock up the UI thread. Microsoft’s asynchronous programming model our best friend and in just a few lines we can wait for a response from DialogBuilder. In this code example we’ll wait for AlertDialog’s positive or negative button being tapped.

This AlertAsync method uses the TaskCompletionSource<TResult> type to create the task and handle the completion. Upon the user tapping the positive or negative button we call TrySetResult() on the TaskCompletionSource to return our bool value.


Happy Coding!

If you are ever working on a Xamarin.Android App and need to dismiss an AlertDialog box when loading SingleChoiceItems here’s an easy way to achieve it.

In the example below we create a new DialogBuilder instance, adding a title and then loading several items as SingleChoiceItems. Then on the DialogClickEventArgs handler grab a reference to the AlertDialog var d; and simply call d.Dismiss() to dismiss dialog, removing it from the screen.

Found myself in need of moving an item stored in an IList to the top of the stack. Some IList methods like RemoveAt() and Insert() would work however wouldn’t be as efficient with a large data set. Fortunately found a Stack Overflow post which would do the move in a single step. I renamed the extension to MoveToTop and here’s a quick and easy Xamarin Workbook sample.


Id: 3 Name: Third
Id: 1 Name: First
Id: 2 Name: Second

Hope someone finds this useful. Feel free to share/like etc.

Some years ago I wrote a handy library Get iOS Model that I open-sourced on Github and through the years I’ve been asked if I would ever create an Xamarin.Android version. Finally got around to it and made it available this week.

The package consists of 18,554 Android devices that support Google Play which I will update regularly.

Using the package is pretty simple:

  1. Install the nuget package dannycabrera.GetDroidModel
  2. Make a call to:

Example: Device model “SM-G960F” will return as “Galaxy S9”.

If you prefer having the manufacturer’s name returned call:

GetDroidModel.DeviceHardware.Model(defaultValue: “Unknown”, includeManufacturer: true);

Example: Device model “SM-G960F” will return as “Samsung Galaxy S9”.

Hope this is a useful library/plugin for all.

Danny Cabrera

Principal Software Engineer at Command Health https://github.com/dannycabrera

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store