March 10, 2015

Like Clockwork, Xamarin Releases Watch Kit Support


We’re very excited to announce official support for Apple’s just-released Watch Kit.

To start building Watch apps with Xamarin immediately:

  • Download the official Xcode 6.2 release from Apple.
  • Update Xamarin.iOS to the latest version.
  • Update Xamarin Studio or the Xamarin for Visual Studio extension.
  • File > New Watch App!

Xamarin provides complete Apple Watch support in both Xamarin Studio and Visual Studio. You can use your favorite IDE to:

  • Create new Watch Apps with an associated Watch Extension.
  • Edit watch user interface storyboards in the iOS Designer.
  • Start and debug watch apps in the iOS Simulator (Visual Studio uses the Mac Build Host).
  • Build and test your watch app Glance and Notification modes.

Visit our Watch Kit documentation and samples to get started, or watch this short Your First Watch Kit App video:

Discuss this blog post in the Xamarin Forums.

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInEmail this to someone
March 6, 2015

Xamarin App Video Spotlight:


At Xamarin Evolve 2014 I sat down with Cristina Noel of, an online catalogue of over 250,000 individual pieces of sheet music. enables musicians to print what they’ve purchased, as well as have unlimited access to it digitally online and via Android and iOS apps.

A Windows desktop app for a long time, decided to move to mobile to allow people to view and play music on the go. Watch the video below to learn how a desire to work smarter, not harder, in updating their C++ Windows app to a new language led them to C# and Xamarin.

Learn More

You can learn more about on their website. Their apps are also available for download on Android and iOS.

To get started developing with the Xamarin platform, check out our developer documentation, or get live online training with Xamarin University.

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInEmail this to someone
March 5, 2015

Xamarin Is Coming to a Campus Near You


This past fall, we announced free Xamarin Indie subscriptions for all currently-enrolled college and high school students. In the few months since, thousands of students have taken us up on our offer and are now building and shipping Xamarin apps for iOS and Android.

As part of this announcement, we also unveiled our Xamarin Student Ambassador program. Students accepted into the program are fostering interest in mobile app development in their peers around the globe by sharing their experience building native mobile apps in C#. This first class of 2014-2015 Xamarin Student Ambassadors includes sixty-four representatives, spanning 27 countries and 5 continents.

Xamarin Student Ambassadors
Our student ambassadors already have a lot of amazing progress to report. From several great blogs covering topics like “Xamarin.Forms and NFC” and “Creating Bindable Custom Controls with Xamarin.Forms”, to our ambassadors in Italy who unified to create a group to serve the students of Milano.

Xamarin Student Ambassadors are on campuses all over the globe and are anxious to share details about upcoming events and find ways to help out in any way they can, so be sure to connect with one near you!

Xamarin Recruiting Near You

In addition to our ambassadors spreading the word about Xamarin all over the world, the Xamarin team is making regular appearances on campuses in the US! If working for team Xamarin is your dream job, we would love to see you at an upcoming information session! We will share a bit about our products, customers, experiences, and discuss the transitions that Xamarin has gone through in the past three years. Stop by, bring your resume, enjoy some good food, and learn why Xamarin was voted one of the San Francisco Business Time’s “Best Places to Work”.

University of California, Berkeley

  • When: Tuesday, March 17th from 5:00-6:30pm
  • Where: The Blue Room
  • RSVP

Stanford University

  • When: Wednesday, April 1st from 6:00pm-8:00pm
  • Where: The Red Lounge
  • RSVP

University of California, Davis

  • When: Monday, April 6th from 12:00pm-2:00pm
  • Where: Internship and Career Center (South Hall)
  • RSVP via the Aggie Job Link
Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInEmail this to someone
March 4, 2015

Android Tips: Faster Maps with Google Maps Lite


Inside Google Play Services is the powerful Google Maps API, which allows you to add a rich and interactive maps control to your Android apps. However, the maps control and API can be heavy, and sometimes you just want to display a simple map with a few markers on top of it. This is where the brand new Google Maps Lite mode can come in handy by providing a bitmap image at a specified location and zoom level, while still giving access to a subset of the full API.

coffee mugThis is perfect for situations when your users don’t need to interact with the map, a map is displayed in a feed of items, or you just need a small map to show with a marker. In my case, I wanted to create an app to flip through a list of nearby coffee shops to help feed my 24/7 coffee obsession. I didn’t want to interact with the map; I just wanted the name, rating, and distance of the coffee shop to be overlaid on top of the map. Let’s go over how to start using Google Maps Lite in an app like this.

Setting Up Your Project

To get started with Google Play Services and Google Maps, you will first need to install the Component or NuGet in your Xamarin.Android project.

Add Google Play Services Component

Obtaining a Google Maps API Key

The next step requires a bit of manual work to obtain your Google Maps API Key from Google, however, we have a great walkthrough to follow on our documentation site. Once you have your key, you will need to update your AndroidManifest.xml with a few meta-data entries and permissions:

<manifest xmlns:android="" android:versionName="4.5" package="" android:versionCode="6">
    <application android:label="@string/app_name">
        <!-- Put your Google Maps V2 API Key here. -->
        <meta-data android:name="" android:value="YOUR_API_KEY" />
        <meta-data android:name="" android:value="@integer/google_play_services_version" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-feature android:glEsVersion="0x00020000" android:required="true" />

Adding a Map in Lite Mode

Enabling Lite mode on a map is extremely simple, as it uses the same classes and interfaces as the full Google Maps API. This means you can add a simple flag to your MapView, MapFragment, or GoogleMap Options.

XML attribute

<FrameLayout xmlns:android=""

In Code Behind

var options = new GoogleMapOptions ();
options.InvokeLiteMode (true);

Initializing the Map

Recently, Google changed how developers should initialize their Maps when using Google Play Services. You must now complete two steps to get your map to appear:

1.) Find your map and create

In your Activity’s OnCreate method, you will need to find your MapView and call its OnCreate method passing in the bundle.

mapView = FindViewById<MapView> (;
mapView.OnCreate (bundle);

2.) Implement IOnMapReadyCallback and Get Map

To get the reference to your GoogleMap (which is what you use to add markers and zoom to a location), you must implement IOnMapReadyCallback on your Activity and then call the MapView’s GetMapAsync method.

public class MainActivity : ActionBarActivity, IOnMapReadyCallback
  GoogleMap googleMap;
  MapView mapView;
  protected override void OnCreate (Bundle bundle)
    base.OnCreate (bundle);
    SetContentView (Resource.Layout.main);
    mapView = FindViewById<MapView> (;
    mapView.OnCreate (bundle);
    mapView.GetMapAsync (this);
  public async void OnMapReady (GoogleMap googleMap)
    this.googleMap = googleMap;
    //Setup and customize your Google Map
    this.googleMap.UiSettings.CompassEnabled = false;
    this.googleMap.UiSettings.MyLocationButtonEnabled = false;
    this.googleMap.UiSettings.MapToolbarEnabled = false;

Move Map to Location

Google Maps Lite is powerful enough to enable you to move the camera to a specific location and even control the Zoom Level. Using the Geolocator Plugin, you can easily zoom the map to your current location:

var position = await CrossGeolocator.Current.GetPositionAsync (10000);
var me = new LatLng (position.Latitude, position.Longitude);
googleMap.MoveCamera (CameraUpdateFactory.NewLatLng (me));

Google Map Initialized

Note the MapsInitializer.Initialize(this);, which must be called before you start interacting with the map.

Adding Markers

With your map up and running, you can now start adding markers or other items to the map. In this case, let’s add a circle indicator at our current location and a full marker at the closest coffee shop:

var coffeeMarker = new MarkerOptions ();
coffeeMarker.SetPosition (new LatLng (coffee.Latitude, coffee.Longitude));
//add marker to map
googleMap.AddMarker (coffeeMarker);
var meMarker = new CircleOptions ();
meMarker.InvokeRadius (16);
meMarker.InvokeStrokeWidth (0);
meMarker.InvokeFillColor (Resources.GetColor (Resource.Color.accent));
//add circle to map
googleMap.AddCircle (meMarker);

Google Map With Pins

Learn More

You can grab the entire source code for my app Coffee Filter, which shows how to use the Google Places API to query nearby coffee locations based on your location. Additionally, you can download Coffee Filter from Google Play on your Android device to try it today.


Be sure to read through Google’s Lite Mode documentation to see all of the available API features when using a map in Lite Mode. To see how to easily integrate more features in Android’s location and maps APIs, be sure to read through our Xamarin documentation to easily integrate them into your Xamarin.Android apps.

Discuss this post in the Xamarin Forums

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInEmail this to someone
March 3, 2015

Xamarin Joins Airwatch, Box, and Cisco in ACE Initiative


We’re excited to announce our participation in the ACE (App Configuration for Enterprise) initiative, announced today at Mobile World Congress, joining Airwatch, Box, Cisco, Workday and other enterprise leaders to create a new industry standard for secure enterprise mobility.

ACE (App Configuration for Enterprise) LogoThis collaboration takes a strong step toward solving the complexities involved with enterprise mobile development (EMM) by creating an open industry standard for secure app management and deployment.

ACE establishes an app configuration standard that interoperates with all EMM vendors, removing the need for developers to write vendor-specific code for app management and distribution. Instead developers write to the ACE specification which covers first-time log-in, verifying network connectivity, simplifying the SSO sign-in process and allowing fine-grain app security controls for all major EMM vendors.

Learn more about how ACE works here.

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInEmail this to someone
March 2, 2015

Follow the Rainbow to Xamarin Events in March!


Find your lucky charm at the end of the rainbow with Xamarin at this month’s developer group events!

meetup-banner March

DFW Mobile .NET us

  • Irving, TX: Thursday, March 5th 6:00PM
  • Automated UI Testing and Monitoring for your Mobile Apps w/ James Montemagno

Kansas City Mobile .NET Developers Group us

  • Kansas City, MO: Tuesday, March 10th 6:00PM
  • Intro to Apple’s WatchKit using Xamarin

Visual Studio ALM Days 2015 __

  • Düsseldorf, Germany: March 11- 12th
  • Automating UI Testing and Xamarin Test Cloud with Mike James

Birmingham Xamarin Mobile Cross Platform User Group __

  • Birmingham,United Kingdom: Wednesday, March 11th 6:30PM
  • A deep dive into Xamarin.Forms

Northern Virginia Mobile C# Developers’ Group us

  • Mc Lean, VA: Wednesday, March 11th 7:00pm
  • Code-sharing with MVVM Cross and Xamarin

Xamarin Meetup San Diego us

  • San Diego, CA: Thursday, March 12th 6:00PM
  • Xamarin User Group Kick-Off!

London: DEVWEEK 2015 __

  • London,United Kingdom: March 23 – 27th
  • MVVM Pattern and Xamarin.Forms workshops with James Montemagno

Windows App London __

  • London,United Kingdom: Wednesday, March 25th 6:30PM
  • What you want to know about Xamarin

Atlanta Xamarin Users Group us

  • Atlanta, GA: Monday, March 30th 6:30PM
  • Intro to Xamarin Forms and Bluetooth LE

Didn’t see your city listed above? Not to worry, look to this Events Forum for even MORE upcoming Xamarin events, meetups, and presentations happening every day!

Want a developer group in your area and are interested in getting one started? We’re here to help! Here’s a tips and tricks guide on staring a developer group, a brand new introduction to Xamarin slide deck, and of course our community sponsorship program to get you on your way. Also, we love to hear from you so please feel free to send us an email or tweet @XamarinHQ to help spread the word and continue to grow the Xamarin community.

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInEmail this to someone
February 27, 2015

Give Us the Gist of It Contest Winners!


Two weeks ago, we asked the community to share the code snippets that help them write amazing apps even faster. Five winners were chosen at random, and here is the gist of it:

Jason Fox:
Snippet Name: Xamarin.iOS Image Blur
Platform: Xamarin.iOS
Function: Image blur extension method for Xamarin.iOS

public static UIImage Blur(this UIImage image, float blurRadius = 25f)
  if (image != null)
    // Create a new blurred image.
    var imageToBlur = new CIImage (image);
    var blur = new CIGaussianBlur ();
    blur.Image = imageToBlur;
    blur.Radius = blurRadius;
    var blurImage = blur.OutputImage;
    var context = CIContext.FromOptions (new CIContextOptions { UseSoftwareRenderer = false });
    var cgImage = context.CreateCGImage (blurImage, new RectangleF (new PointF (0, 0), image.Size));
    var newImage = UIImage.FromImage (cgImage);
    // Clean up
    imageToBlur.Dispose ();
    context.Dispose ();
    blur.Dispose ();
    blurImage.Dispose ();
    cgImage.Dispose ();
    return newImage;
  return null;

Runar Ovesen Hjerpbakk:
Snippet Name: Async and await together with UIAlertController
Platform: Xamarin.iOS
Function: This snippet shows how to use a TaskCompletionSource to enable async and await together with UIAlertController.

public static class CustomerFeelingSheet {
 public static Task<CustomerFeeling> ShowRatingDialogAsync(UIViewController parent) {
   var taskCompletionSource = new TaskCompletionSource<CustomerFeeling>();
   var alert = UIAlertController.Create("howDoYouFeel".T(), null, UIAlertControllerStyle.ActionSheet);
   alert.AddAction(UIAlertAction.Create("likeIt".T(), UIAlertActionStyle.Default,
       a => taskCompletionSource.SetResult(CustomerFeeling.LikeIt)));
   alert.AddAction(UIAlertAction.Create("couldBeBetter".T(), UIAlertActionStyle.Default,
       a => taskCompletionSource.SetResult(CustomerFeeling.CouldBeBetter)));
   alert.AddAction(UIAlertAction.Create("cancel".T(), UIAlertActionStyle.Cancel,
       a => taskCompletionSource.SetResult(CustomerFeeling.DontCare)));
   parent.PresentViewController(alert, true, null);
   return taskCompletionSource.Task;

Matthieu Guyonnet-Duluc:
Snippet Name: Android Behavior – WPF Style
Platform: Xamarin.Android
Function: Reproduce the beloved WPF behaviors in Android

        local:View="@+id/resultsList" />
    public class ListViewHideKeyboardOnScroll : Behavior<AbsListView>
        public ListViewHideKeyboardOnScroll(Context context, IAttributeSet attrs)
            : base(context, attrs)
        #region implemented abstract members of Behavior
        public override void OnAttached()
            View.ScrollStateChanged += HideKeyboard;
        public override void OnDetached()
            View.ScrollStateChanged -= HideKeyboard;
        void HideKeyboard(object sender, AbsListView.ScrollStateChangedEventArgs e)
            if (e.ScrollState == ScrollState.TouchScroll)
                var inputManager = (InputMethodManager)this.Context.GetSystemService(Context.InputMethodService);
                inputManager.HideSoftInputFromWindow(View.WindowToken, HideSoftInputFlags.None);

Ken Pespisa:
Snippet Name: SQLite Extension methods for Save & Delete
Platform: Xamarin.iOS
Function: Save the specified entity by calling insert or update, if the entity already exists.

public static class SQLiteExtensions
   /// <summary>
   /// Save the specified entity by calling insert or update, if the entity already exists.
   /// </summary>
   /// <param name="pk">The primary key of the entity</param>
   /// <param name="obj">The instance of the entity</param>
   /// <typeparam name="T">The entity type.</typeparam>
   public static int Save<T>(this SQLiteConnection db, object pk, object obj) where T : new()
       if (pk == null || db.Find<T>(pk) == null)
           return db.Insert(obj);
       return db.Update(obj);
   /// <summary>
   /// Delete entities based on a predicate function
   /// </summary>
   /// <param name="predicate">The predicate specifying which entities to delete</param>
   /// <typeparam name="T">The entity type.</typeparam>
   public static void Delete<T>(this SQLiteConnection db, Expression<Func<T, bool>> predicate) where T : new()
       var records = db.Table<T>().Where(predicate).ToList();
       foreach (var record in records)

Ryan Davis:
Snippet Name: InlineTableViewSource
Platform: Xamarin.iOS
Function: A subclass of UITableViewSource that allows you to define UITableViewDataSource and UITableViewDelegate methods inline, rather than subclassing.

var cellId = new NSString("cell");
var tableView = new UITableView(View.Frame, UITableViewStyle.Grouped) {
    Source = new InlineTableViewSource {
            _NumberOfSections = (tv) => 2,
            _RowsInSection = (tv, section) => 5,
            _TitleForHeader = (tv, section) => String.Format("Section {0}", section),
            _GetCell = (tv, indexPath) => {
                var cell = tv.DequeueReusableCell(cellId) ?? new UITableViewCell(UITableViewCellStyle.Default, cellId);
                cell.TextLabel.Text = "hi";
                return cell;

Find even more speedy code snippets for your apps in the Get The Gist forum thread, and a big thanks to all who participated in the Give Us the Gist of It Contest!

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInEmail this to someone
February 26, 2015

Join Xamarin for GSMA Mobile World Congress 2015


Mobile World Congress LogoXamarin will take the stage alongside Airwatch, Box and Salesforce in Barcelona at Mobile World Congress next week.
Xamarin’s Director of Enterprise Mobility, Steve Hall, will join the Steve Hall“Airwatch Presents a New Standard for Enterprise App Development” panel discussion on March 2nd. Employees expect – and need – fast, on-the-go access to company data, and we’ll share how enterprises can successfully build and distribute secure mobile apps.

AirWatch Presents a New Standard for Enterprise App Development featuring Box, Salesforce & Xamarin

Tuesday, March 3, 1:30 – 2:25 pm CET
AirWatch Connect Stand
Hall 3, Stand 3D10
All MWC Attendees are welcome to attend.

See you in Barcelona!

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInEmail this to someone
February 25, 2015

Triggers in Xamarin.Forms


Triggers were introduced in Xamarin.Forms 1.3 along with Behaviors, which we covered previously. Triggers allow you to declaratively express actions in XAML that are executed when a specified condition is met. Xamarin.Forms support four types of triggers:

  • Property Trigger – executed when a property on a control is set to a particular value.
  • Data Trigger – same as the property trigger but uses data binding.
  • Event Trigger – occurs when an event occurs on the control.
  • Multi Trigger – allows multiple trigger conditions to be set before an action occurs.

Let’s take a look at each one in detail.

Property Trigger

Property Triggers (represented by the Trigger element) are added to a control’s Triggers collection. The Setter collection inside is executed when a specified property equals the specified value.


Wouldn’t it be nice to provide some visual indicator that an input control has focus? To achieve this, we can set the BackgroundColor property when the property IsFocused of the Entry element is true.

<Entry Placeholder="enter name">
        <Trigger TargetType="Entry"
             Property="IsFocused" Value="True">
                Value="Yellow" />

Alternatively, we can set them in styles so that they can be attached to every Entry element in the screen.

     <Style TargetType="Entry">
       <Setter Property="AnchorX" Value="0" />
         <Trigger  TargetType="Entry"
           <Setter Property="BackgroundColor"
                   Value="Yellow" />

Data Trigger

DataTriggers are very similar to PropertyTriggers, except that instead of specifying the Property, we specify the Binding for the trigger. This Binding generally refers to another VisualElement’s property on the page or it could reference a property in a ViewModel.

The code below shows how to disable the button when the entry’s Text.Length property is 0.

<StackLayout Spacing="20">
<Entry x:Name="emailAddress" Text="" Placeholder="email address"/>
<Button Text="Send">
    <DataTrigger TargetType="Button"
         Binding="{Binding Source={x:Reference emailAddress},
      <Setter Property="IsEnabled" Value="False" />

Event Trigger

Event Triggers execute user-defined code when a specified event occurs.

In the above Property Trigger example, we saw how to change the background color of an Entry element based on the IsFocused property entirely in XAML. Alternatively, we can use an Event Trigger to execute an action written in C# based on the TextChanged event of an entry to perform some basic validation.

Define the TriggerAction in code

Every action that we define has to inherit from TriggerAction<T> where T is the element to which a trigger is attached. When a trigger is fired, the Invoke method will be called. In the code below, we change the Entry’s BackgroundColor to indicate whether the input is valid or not.

public class NumericValidationTriggerAction : TriggerAction<Entry>
   protected override void Invoke (Entry entry)
      double result;
      bool isValid = Double.TryParse (entry.Text, out result);
      entry.BackgroundColor =
            isValid ? Color.Default : Color.Red;

TriggerAction in XAML

To use the C# code, just declare a namespace for the assembly (xmlns:local in this sample) and add the NumericValidationTriggerAction element to the event trigger:

<Style TargetType="Entry">
    <EventTrigger Event="TextChanged">
        <local:NumericValidationTriggerAction />

Multi Trigger

A MultiTrigger looks similar to a Trigger or DataTrigger except there can be more than one condition. All the conditions must be true before the Setters are triggered.

In the code below, we enable the button when either the email or the phone entries are filled in by the user. Each condition is true when the length of the text input is zero (ie. nothing has been entered). When both conditions are true (ie. both are empty) then the trigger’s Setters are called, which in this case disables the button. When either have text entered, the overall condition becomes false and the button is enabled.

<Style TargetType="Button">
  <MultiTrigger TargetType="Button">
          Binding="{Binding Source={x:Reference email},
          Value="0" />
          Binding="{Binding Source={x:Reference phone},
          Value="0" />
    <Setter Property="IsEnabled" Value="False" />

To see how to build a “require all” trigger (like you’d use in a login page, for example) check out our Triggers sample on GitHub that uses an IValueConverter along with a MultiTrigger.

For even more information on Xamarin.Forms, be sure to check out the detailed documentation.

Discuss this post in the Xamarin forums

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInEmail this to someone
February 24, 2015

Live APAC Webinar: Go Mobile with Xamarin


Photo of Mayur Tendulkar

Join Xamarin Evangelist Mayur Tendulkar for this live webinar timed just for our APAC customers, where you’ll learn how to leverage your existing Microsoft .NET and C# skills to build iOS, Android, and Windows Phone apps using Visual Studio and Xamarin. We’ll also talk about how to maximize code sharing and reuse existing .NET libraries.

At the end of the webinar, you’ll have the skills you need to create your first iOS and Android apps in C# with Xamarin in Visual Studio.

View the Webinar Recording

You can view the video of this previously recorded webinar here.

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInEmail this to someone