March 31, 2015

Live APAC Webinar: Say Hello to Xamarin.Forms


Photo of Nish AnilIn this live webinar, Xamarin Developer Evangelist Nish Anil will introduce you to Xamarin.Forms. You’ll learn how to use the Xamarin.Forms API to quickly build shared screens for iOS, Android, and Windows Phone, and about various Xamarin.Forms components, including Pages, Views, Layouts, and DependencyServices, and how to use them to create truly native cross-platform apps.

At the end of this session, you’ll be able to build Xamarin.Forms apps for iOS, Android, and Windows Phone.

Thursday, April 16
11:30 AM – 12:30 PM IST


All of the registrants for the webinar will receive a copy of the recording, so please feel free to register even if you won’t be able attend the day of the event.

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

Creating Beautiful iOS Controls with PaintCode


Delivering a beautifully designed app can be the difference between having an app that gets used, or having an app that no one notices. Of course, having a beautiful app doesn’t just happen – creating something different often means creating your own custom controls, and creating beautiful custom controls on iOS can be a difficult task without intimate knowledge of CoreGraphics. This is where PaintCode steps in. PaintCode is a vector drawing app that generates C# code in real-time, allowing you to design your iOS controls and export the resulting “drawing code”. This is great because it allows you to create resolution-independent controls that will look great on any size of device.

From the beginning, the Xamarin Designer for iOS has supported real-time rendering of custom controls, which allows you to see instant feedback on your code changes. A number of developers have been opting to use images for control customization, which leads to a series of issues including bloating your app store binary size and that these images simply won’t scale properly on new screen sizes that Apple may release in the future.

PaintCode on Mac


PaintCode can generate a special class that contains all of the drawings, colors, gradients, shadows, and other design assets used in your app. In the following example, I’ve named the StyleKit DemoStyleKit. You’ll want to make sure you’re regularly exporting the StyleKit from PaintCode into your Xamarin project in order for changes to be made available to you in your project. Exporting your style sheet will create a .cs style and copy any images your styles use into the directory of your choice. Once you’ve done this, you’ll need to add these to your existing Xamarin.iOS project.

Creating a custom control

Once you’ve added the exported files, you’re ready to consume the drawing code in a custom control. You will need to create a new class which will be your custom control; in this sample I’ve called it ‘MyTimerView’ and it inherits from UIView.

It’s here where we’ll consume the auto-generated C# from PaintCode and set it up to support the Storyboard designer. In this example, I annotate the class with the DesignTimeVisible attribute. This tells our iOS Storyboard designer that I wish to use this class within the Storyboard designer. A basic class with Storyboard support should look something like this:

Register("MyTimerView"), DesignTimeVisible(true)]
public class MyTimerView : UIView
  public MyTimerView(IntPtr p) : base(p)
    Initialize ();
  public MyTimerView ()
   Initialize ();
  void Initialize ()
  public override void Draw(CoreGraphics.CGRect rect)

Because PaintCode exports the drawing code into the StyleKit, we can implement the drawing with just one line of code!

public override void Draw(CoreGraphics.CGRect rect)
  DemoStyleKit.DrawTimer(rect, Angle);

If you save and build the project now and open your Storyboard, you should find MyTimerView within the control toolbox. You can drag and drop this into your view and instantly see how it looks.

A custom control in the iOS storyboard designerAdvanced properties

It would be great to be able to control the angle of the green progress line from the Properties panel within our IDE. Fortunately, custom controls allow for design time properties for a number of types, including string, bool, SizeF, UIColor, and UIImage. To add an angle property to our properties pad, let’s add the following to our class:

float angle;
[Export("Angle"), Browsable(true)]
public float Angle
  get { return angle; }
    angle = value;
    SetNeedsDisplay ();

It’s also worth ensuring that the _angle property has an initial value by setting it in the Initialize method. Once you’ve done this, you’ll see a new property available to you and the changes to the value will automatically be updated in the custom control. This allows you to create very customizable controls without needing to drop into code to make tweaks.

Learn more

You can learn more about PaintCode on their website and purchase the app from the Mac App Store.

To get started, download the sample project from this blog post from GitHub.

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

Contest: What’s Beggin’ for a Beacon?


Yesterday, we put the spotlight on our beacons partners and today we’re inviting you to put on your creativity hat and dive into the world of context.

What are Beacons?

Beacons are small pieces of hardware that use Bluetooth technology to transmit signals to mobile devices, allowing developers to create context-aware apps. Our Component Store partners make it easy to build apps that detect beacon signals and can act accordingly, sending push notifications, coupons, or other information to a central database.


The bottom line: beacon potential is everywhere, from simple life productivity hacks to innovative business improvements. Share a picture, video, or brief description of something you think should be beacon-enabled – however practical or impractical – and we’ll award prizes to our favorite ideas.

How to Enter:

  • Submit your idea, including why it’s “beggin’ for a Beacon,” using a written description, video, and/or photos
  • Tweet your idea to @xamarinHQ with the hashtag #BeaconPotential
  • Bonus points: link to your blog about your Beacon idea for the contest!

Example Tweet:

Always losin’ Fido. @XamarinHQ #BeaconPotential
Whiskey, Xamarin Office Dog


Most Creative Idea wins a Xamarin + Beacons extravaganza!

  • BKON hardware
  • MobStac swag and Rasberry Pi 2 kits
  • Estimotes beacon devkit & assorted swag
  • Xamarin swag

Real Potential

Do you have the next Fido finder app in the works? We’re on the lookout for submissions that have real potential! One submission will be eligible for a special prize from our beacons partners.

Special Prize:

Special prize for one lucky contestant whose submission has the most real-world applicability: our beacons partners are offering a 1:1 mentorship session to share their expertise. They will guide you through best practices for context-aware apps to help get your app off the ground – and provide beacon hardware to get you up and running.

Rules and Regulations:

All entries must be submitted by April 6th at 12pm EST. A valid entry is a tweet that highlights a unique, creative and useful Beacon use case and includes both @xamarinhq and the hashtag #BeaconPotential. We will review and evaluate your submissions based on a variety of factors, including creativity and number of likes, retweets, and shares. Contestants should follow @XamarinHQ to enable us to DM you for private follow-up if you win a prize. This contests is open to individuals and there is no purchase necessary to enter.

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

Win an Apple Watch Contest Winner!


A couple of weeks ago we invited you to start creating your first WatchKit app using the Xamarin Storyboard designer for a chance to win an Apple Watch. With all of the excitement around this cool new device, we weren’t surprised when we got a ton of great submissions!

With a lot of thought and tough decision making, we’re pleased to announce that the winner of the contest is:

Car Parking App!

A huge thank you for all of the wonderful submissions; it was a truly difficult choice to pick just one. For more Apple Watch inspiration, check out this forum to see other examples from the contest!

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

Xamarin Webinar Featuring Gartner: The Next 20 Million Apps


Gartner logoIn the near future, nearly every transaction and interaction will need to have a mobile surface, and millions of new apps will be required over the next few years to really achieve the promise of enterprise mobility to transform customer relationships and business processes.

How will the enterprise achieve this? Through scalable ways to build, test, integrate, and manage apps across a diverse and dynamic device landscape that is quickly moving beyond smartphones and tablets to wearables and M2M computing.

To help mobile leaders navigate this next phase of mobility, we invite you to register now for our April 9th webinar with Analyst firm Gartner, featuring Richard Marshall, Research Director of Enterprise Mobility at Gartner, and Xamarin’s Director of Enterprise Mobility, Steve Hall.

Register Now

About the Speakers

Richard Marshall, GartnerRichard M. Marshall is a Research Director in the Mobile and Client Computing group, focusing on enterprise mobility and especially mobile apps and mobile app development.He has experience across a wide range of software industry skills, from coding to corporate governance. This includes all phases of product development from initial concept through implementation and on to sales, product management and marketing. He is an inventor of software technology and has lectured and written papers, articles and reports for many years. Mr. Marshall has held a variety of leadership roles, including CTO, VP of Engineering and CEO. He has had extensive success in raising capital from angel and institutional investors.
Steve HallSteve Hall works with Xamarin’s enterprise customers providing guidance and best practices for implementing mission-critical mobile solutions in an enterprise setting. He has over fifteen years of mobile experience that covers enterprise mobile architecture, security, and development. In the span of his career, Steve has also designed secure mobile solutions for large enterprises, consumer applications, and government agencies.

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

Xamarin Tech Partner Update: Spotlight on iBeacons


We’ve been busy growing our mobile ecosystem over the past year, and the Xamarin Component Store now features over 300 components that allow developers to easily integrate new functionality into their apps. Features ranging from cloud services and backend systems integration to charts, graphs, and datagrids can be added with just a few lines of code. Today, we’re excited to highlight our beacons partners BKON, Estimote, and MobStac.

These partnerships give Xamarin developers the power to detect beacons with simple integrations, expanding on our mission to make it fast, easy, and fun to build great mobile apps.
Estimote LogoIn mobile, context is king, and Estimote, MobStac, and BKON allow developers to build context-aware apps using micro-location data to send information to the users’ device. Beacons can be used to improve customer relationships by sending relevant information instead of “spam” ads, to drive increased revenue for businesses by informing shop associates when customers are interested in objects, and to speed transactions with automatic check-in.
Mobstac LogoBeaconstac by MobStac is a hardware-agnostic cloud service, allowing developers to use any beacon vendor of choice, including Estimote, to tap into MobStac’s robust content management, reporting, and analytics capabilities. With MobStac, users can use iBeacon data to detect high-traffic retail areas, to target specific users based on CRM data, or to push certain product catalog information based on in-store location.
BKON LogoBKON and Estimote provide both beacon hardware and Xamarin Components to detect beacon transmissions. BKON offers two beacon hardware variants, as well as security and management for deployed beacons, giving customers the ability to detect battery levels, set passwords, and more. With Estimote and Estimote Stickers, beacons become even more portable. Users attach a beacon to objects, allowing any device or item to become a “nearable”: a mini smart-machine, broadcasting data to devices in range. This takes contextual targeting even further, allowing, for example, sales associates to be alerted when a customer engages with an item or museum curators to adjust exhibit displays based on visitor interaction.

Our partnerships with Estimote, MobStac, and BKON make building native, context-aware apps simple, allowing your customers to remain relevant, gain competitive advantage, deliver better user experiences, drive additional purchases, and leverage user behavior to identify areas for growth.

Get started with BKON, Beaconstac by MobStac, and Estimote (iOS and Android) today.

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

Add Storage to Your Apps with Office 365


Enterprises with a Bring Your Own Device (BYOD) strategy face the challenge of securing their resources on various types of devices. For example, organizations want to share documents with their employees, allow them to collaborate on documents with coworkers, and more. Employees want to sync these documents with a variety of devices, such as tablets, laptops and mobile phones, with a seamless search experience. These challenges can be tackled by using OneDrive for Business, which is part of Office 365.

Xamarin developers can use OneDrive for Business in their iOS and Android apps to download, open, edit, and upload files in Office 365 (O365). In this post, we’ll build a simple Xamarin.Android app that can connect to OneDrive for Business to show a list of files.

Note 1: To build apps that can connect to Office 365, you’ll need an active subscription. Also, to follow the steps manually as mentioned in this blog, you’ll need to access the O365 associated Active Directory.

Note 2: The APIs, libraries, sample code and registration process are currently in preview. This blog post is intended to show the possibilities of using O365 with Xamarin.

Step 1: Register the app

As we’ve seen before, Office 365 uses Azure Active Directory (AD) as the Identity Provider. Which means that Azure Active Directory is used to authenticate and authorize users. To allow OneDrive to be accessed from mobile apps, it is mandatory to register this app in AD. You can follow our guide to registering an app with Active Directory to learn how.

Step 2: Give access to the O365 APIs

On the Configure tab, click the Add Application button at the bottom.


On next screen, select Office 365 SharePoint Online to access the Files and Lists.


Once these services are selected, give access to the tasks that a user can perform with the app on the next screen.


Now we can Save this configuration and focus on the mobile part of our app.

Step 3: Build mobile app

Step 3a: Refer NuGet packages

In order to use O365 services in your Xamarin app, you will need to add the following NuGet packages to your project.

  • Azure Active Directory Authentication Library (ADAL) – v3.0.11xx (Preview/Alpha)
  • Microsoft Office 365 My Files Library for .NET – v1.0.22 (Stable)
  • Microsoft Office 365 Discovery Library for .NET – v1.0.22 (Stable)

Step 3b: Declare variables

Add a new class to your project and name it AuthenticationHelper. Declare the variable at class and global level as outlined below:

public static readonly string DiscoveryServiceResourceId = "";
public const string Authority = "";
public static readonly Uri DiscoveryServiceEndpointUri =
new Uri("");
public static Uri returnUri = new Uri("http://Xam-O365-Integration");
public static string clientId = "32088804-9284-451f-9ee6-2b70507a99cf";
public static AuthenticationContext authContext = null;

Step 3c: Write method to acquire AccessToken

Using ADAL, this app will fetch the Access Token from AD, as shown below. In this method, the second parameter will depend on the platform on which the code is executing. For example, in Android an Activity is passed, but on iOS and Windows Phone the second parameter is not required.

public static async Task<AuthenticationResult> GetAccessToken (string serviceResourceId, Activity activity)
   authContext = new AuthenticationContext(Authority);
   if (authContext.TokenCache.ReadItems().Count() > 0)
      authContext = new AuthenticationContext(authContext.TokenCache.ReadItems().First().Authority);
      var authResult = await authContext.AcquireTokenAsync(serviceResourceId, clientId, returnUri, new AuthorizationParameters(activity));
   return authResult;

Step 3d: Create DiscoveryClient

Discovery Service helps find Service Endpoints. Create a new method GetDocumentsList(), which will create DiscoveryClient for further use.

List<string> fileNames = new List<string>();
DiscoveryClient discoveryClient = new DiscoveryClient(
async () =>
var authResult = await AuthenticationHelper.GetAccessToken(AuthenticationHelper.DiscoveryServiceResourceId, this);
return authResult.AccessToken; });
var appCapabilities = await discoveryClient.DiscoverCapabilitiesAsync();
var myFilesCapability = appCapabilities.Where(s => s.Key == "MyFiles")
    .Select(p =>; new { Key = p.Key,
    ServiceResourceId = p.Value.ServiceResourceId,
    ServiceEndPointUri = p.Value.ServiceEndpointUri })

Step 3e: Create SharePointClient

Files in OneDrive or Lists from SharePoint in O365 can be accessed using SharePointClient. This object again encapsulates REST services provided by O365.

if (myFilesCapability != null)
SharePointClient myFilesClient = new SharePointClient(myFilesCapability.ServiceEndPointUri,
async () =>
var authResult = await AuthenticationHelper.GetAccessToken(myFilesCapability.ServiceResourceId, this);
 return authResult.AccessToken;
var myFilesResult = await myFilesClient.Files.ExecuteAsync();
var myFiles = myFilesResult.CurrentPage;
foreach (var myFile in myFiles)
myFilesResult = await myFilesResult.GetNextPageAsync();
} while (myFilesResult != null);

Step 3f: List files

By default, MainActivity is derived from Activity. Change this behavior to derive from ListActivity to display a list in the app.

Just after the above code, create an adapter and use it to show the list of documents.

this.ListAdapter = new ArrayAdapter(this,

Last, call this ‘fat’ GetDocumentsList method from the OnCreate method and run the app. It should show the following result, listing files from your OneDrive account.


Now you’ve got a fantastic foundation to build multi-tenant, intranet, integrated mobile apps using Office 365. Office 365 has a huge number of features which we’ll be highlighting in future guides and samples apps.

If you’re interested in exploring a sample project, you can download a copy of the source code from this blog post on GitHub and discuss this topic in forums.




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

Android Tips: Immersive Panoramic Google Maps


Displaying a map in your app can add a lot of context for a specific location. You can also take things a step further, though, and create a fully immersive experience to help your users get where they need to be.Panorama View Control Android This can be accomplished in just a few lines of code with the Street View Panorama View control.

Previously, I covered how to use Google Maps Lite in your Xamarin.Android apps for displaying non-interactive, light-weight maps. For the Panorama View, you will go through the same setup process of adding Google Play Services to your project and settings up your Google Maps API Key. In this example, we will add more context our Coffee Filter app by adding a button to navigate to the Street View page.

Add a StreetViewPanoramaView

The first step is to add a new layout. We are going to simply fill the entire page with a StreetViewPanoramaView as we want to fully immerse our users in the street view. You can of course embed the control into an existing page and make it any size you wish.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
        android:layout_gravity="center" />

Setting up the Activity

Similar to using Google Maps, we will need to implement a callback, IOnStreetViewPanoramaReadyCallback, in our Activity and initialize our StreetViewPanorama.

public class PanoramaActivity : ActionBarActivity, IOnStreetViewPanoramaReadyCallback
  StreetViewPanoramaView streetViewPanoramaView;
  StreetViewPanorama streetPanorama;
  LatLng latlng;
  protected override void OnCreate (Bundle bundle)
    base.OnCreate (bundle);
    SetContentView (Resource.Layout.panorama);
    //pass in lat/lng from parent activity
    var lat = Intent.GetDoubleExtra ("lat", 37.7977);
    var lng = Intent.GetDoubleExtra ("lng", -122.40);
    //create LatLng to display
    latlng = new LatLng (lat, lng);
    //find our panorama view and create async.
    streetViewPanoramaView = FindViewById<StreetViewPanoramaView> (Resource.Id.panorama);
    streetViewPanoramaView.OnCreate (bundle);
    streetViewPanoramaView.GetStreetViewPanoramaAsync (this);

The IOnStreetViewPanoramaReadyCallback interface has one method to implement OnStreetViewPanoramaReady. This will pass your StreetViewPanorama that you use to set certain properties and set the position to display. We will turn on just about every feature, and set the position to the position that was passed in from the parent activity.

public void OnStreetViewPanoramaReady (StreetViewPanorama panorama)
  this.streetPanorama = panorama;
  streetPanorama.UserNavigationEnabled = true;
  streetPanorama.StreetNamesEnabled = true;
  streetPanorama.PanningGesturesEnabled = true;
  streetPanorama.ZoomGesturesEnabled = true;
  streetPanorama.SetPosition (latlng);

In addition to this, it’s best practice to override OnResume, OnPause, OnDestroy, OnLowMemory, and OnSaveInstanceState in your Activity and call the matching methods on your StreetViewPanoramaView control. If you don’t want to wire the lifecycle events yourself, there’s also a Fragment & SupportFragment version of the StreetViewPanorama that will handle this for you automatically.

Full Immersion

In Android KitKat, Google introduced a new API called Immersive Full-Screen mode for an Activity. This enables your app to extend all the way into the status and navigation bars on the device. To take advantage of this, you simply need to add a few lines of code in your Activity, setting the SystemUiVisibility of the DecorView.

public override void OnWindowFocusChanged (bool hasFocus)
  base.OnWindowFocusChanged (hasFocus);
  if (hasFocus && (int)Build.VERSION.SdkInt >= 19) {
    Window.DecorView.SystemUiVisibility =
        | SystemUiFlags.HideNavigation
        | SystemUiFlags.LayoutFullscreen
        | SystemUiFlags.Fullscreen
        | SystemUiFlags.ImmersiveSticky);

We now have a fully immersive, beautiful Street View Panorama View in our app!

In Motion Panorama

Learn More

To get started, be sure to download the Google Play Service component from the Component Store for your Android apps. Read through the entire Street View documentation from Google for advanced options. We also have a full sample of adding Immersive mode to your Xamarin.Android apps. You can find the full source code for this sample and Coffee Filter on my GitHub.

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

Exciting Xamarin Announcements from dotnetConf


Miguel and I just had the honor of helping kick off day two of dotnetConf, along with our good friend Scott Hanselman. dotnetconf logo
dotnetConf is a two-day virtual event, dedicated to all things .NET and to highlighting our vibrant developer community. We had a few exciting announcements to share with everyone, which you can watch for yourself in the recording below, or read about in the summary that follows.

Xamarin.Forms for Windows Preview

Xamarin.Forms for Windows Store

We launched Xamarin.Forms a year ago, enabling developers to rapidly create native applications for iOS, Android, and Windows Phone from a single shared C# code base. One of our most popular samples from that launch is an app dedicated to all things Scott Hanselman – aptly named Hanselman.Forms.

For today’s intro with Scott, I couldn’t resist taking the opportunity to re-launch Hanselman.Forms with podcast streaming and a few new bells and whistles showing off the latest features available in Xamarin.Forms, such as pull-to-refresh. But the fun didn’t stop there, as we capped off the demo with the exciting announcement of our preview support for building for Windows Store and Phone RT when developing with Xamarin.Forms.

Hanselman.Forms on All Devices

Xamarin.Forms for Windows Preview is available now on NuGet as a pre-release package. This is a very early preview that we’re making publicly available to get as much feedback as possible from the community as we stabilize our Windows support over the next few months. To get started, simply add a new Windows Store app to your existing solution and with a few lines of initialization code and you are on your way. We have full documentation for this preview available on our developer portal, and you can download and run the source for Hanselman.Forms straight from GitHub.

Xamarin Everywhere

The theme of today’s talk was “.NET deserves to be everywhere”, so in addition to extending the Hanselman app to Windows Store, I also took the opportunity to update it with support for wearable platforms, because I know that everyone wants mission-critical Hanselman updates on their wrist. Now, you will find a brand new Android Wear and Apple Watch app as part of the Hanselman.Forms project with plenty of awesome shared C# code, and you can start building your own wearable apps today with WatchKit in Xamarin.iOS, or by referencing the Android Wear Component or NuGet in your Xamarin.Android projects.


Xamarin Subscriptions for OSS Contributors

We love the .NET community and are dedicated to supporting the huge community of .NET developers working on powerful NuGets like PCLStorage, SQLiteNet and other plugins for Xamarin and Windows.

Xamarin Heart OSS

To ensure that all open source projects have everything they need to succeed, today we also announced the expansion of our our support for OSS developers to include free Xamarin subscriptions with support for Visual Studio. Any open source developers with app store compatible licenses receive non-commercial Xamarin subscriptions for the purpose of developing, testing and maintaining compatibility with the Xamarin platform. Active developers on established open source projects can apply now.

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

Microsoft Band SDK Now Available


Microsoft just announced iOS support for their recently released Microsoft Band SDK. The iOS preview joins their preview support for Android and Windows Phone, and we’re delighted to announce that within 24 hours of release, we’ve made these SDKs available to Xamarin developers on iOS and Android, too. Microsoft Band

The Band is very much designed for health and fitness with its many sensors, but it is not limited to health uses. Because we have access to the sensors and can interact with the device, we can use the Band to enhance and extend any mobile app.

There are 4 main ways we can interact with the Band:

  1. Reading information from the Sensors
  2. Creating themed app Tiles
  3. Sending Messages to the Band
  4. Theming and Personalizing the Band

To interact with a Band from your app, install the SDK and add the code to create a connection with a Band. The user will need the Microsoft Health app installed, and have paired their Band with their phone.

Once connected you can communicate with the Band easily using C# in your iOS and Android apps. The APIs allow you read from the various Band sensors, send messages that appear on the band while it’s connected, and much more.

Getting Started

To start building Band apps with Xamarin today, add the Microsoft Band SDK Component to your iOS or Android project, check out the component documentation and my samples for iOS and Android to learn how to connect and read sensor data.

Discuss this blog post in the Xamarin Forums.

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