August 5, 2015

Put Some Azure Active Directory in Xamarin.Forms


The Azure Active Directory Authentication Library (aka ADAL) makes authentication with Azure Active Directory a breeze. We’ve already covered usage of ADAL in various posts on authenticating with Active Directory, adding storage, and adding collaboration (SharePoint) to your mobile apps. azure-active-directoryADAL is available for various platforms and supports Xamarin.Android, Xamarin.iOS, and Windows Phone. It’s easy to integrate ADAL into these projects by adding a NuGet package. Although ADAL hasn’t released a specific Package for Xamarin.Forms, there have been many questions in the Xamarin forums and on StackOverflow about how to use ADAL in a Xamarin.Forms app.

Recently, Vittorio Bertocci, Principal Program Manager at Microsoft, posted a blog about integrating ADAL into Xamarin.Forms apps using a PageRenderer. In this post, I’ll be sharing another way to integrate ADAL into Xamarin.Forms apps using Dependency Service, which is available in Xamarin.Forms.


Step 1: Create a Xamarin.Forms App

Create a Xamarin.Forms app in Xamarin Studio or Visual Studio. If you create this project with Visual Studio, it will create four projects: PCL, Android, iOS, and Windows Phone. In this solution, the Windows Phone project created with Xamarin.Forms uses the Silverlight framework, which has different requirements for implementing ADAL than iOS, Android, or Windows Runtime apps. So let’s add a Windows Phone 8.1 project, for which we’ll use the new Windows Runtime framework by following the steps in the documentation. Follow the guide and make sure your project structure looks similar to my solution below:


Step 2: Add NuGet Package References

For each project (excluding Windows Phone 8.0 Silverlight), add an ADAL NuGet package (currently pre-release). The same NuGet package with the same version should get added to each platform project.


Step 3: Create IAuthenticator Interface

In your PCL, add a new interface with the Authenticate method. It should return AuthenticateResult from ADAL, which contains the AccessToken and other details that are required for further API calls.

public interface IAuthenticator
  Task<AuthenticationResult> Authenticate(string authority, string resource, string clientId, string returnUri);

Step 4: Create IAuthenticator Implementations

The Authenticate method body is almost the same in each platform. The only change that occurs is different parameters for PlatformParameters, which governs the authentication flow and maintains the context of the app.

Let’s review the implementations one at a time.

Android Implementation

PlatformParameters needs an Activity in Android, and in Xamarin.Forms you can cast Forms.Context to grab the main Activity. The entire implementation in your Android project would look like this:

[assembly: Dependency(typeof(ADALForForms.Droid.Helper.Authenticator))]
namespace ADALForForms.Droid.Helper
  class Authenticator : IAuthenticator
    public async Task<AuthenticationResult> Authenticate(string authority, string resource, string clientId, string returnUri)
      var authContext = new AuthenticationContext(authority);
      if (authContext.TokenCache.ReadItems().Any())
        authContext = new AuthenticationContext(authContext.TokenCache.ReadItems().First().Authority);
      var uri = new Uri(returnUri);
      var platformParams = new PlatformParameters((Activity)Forms.Context);
      var authResult = await authContext.AcquireTokenAsync(resource, clientId, uri, platformParams);
      return authResult;

Apart from this, you’ll also need to override the OnActivityResult method in the MainActivity.cs file, which will continue the authentication flow.

protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
  base.OnActivityResult(requestCode, resultCode, data);
  AuthenticationAgentContinuationHelper.SetAuthenticationAgentContinuationEventArgs(requestCode, resultCode, data);

iOS Implementation

For iOS, PlatformParameters accepts a UIViewController to maintain the context. We can set RootViewController to use it as context, so the implementation on iOS should be as follows:

[assembly: Dependency(typeof(ADALForForms.iOS.Helper.Authenticator))]
namespace ADALForForms.iOS.Helper
  class Authenticator : IAuthenticator
    public async Task<AuthenticationResult> Authenticate(string authority, string resource, string clientId, string returnUri)
      var authContext = new AuthenticationContext(authority);
      if (authContext.TokenCache.ReadItems().Any())
        authContext = new AuthenticationContext(authContext.TokenCache.ReadItems().First().Authority);
      var controller = UIApplication.SharedApplication.KeyWindow.RootViewController;
      var uri = new Uri(returnUri);
      var platformParams = new PlatformParameters(controller);
      var authResult = await authContext.AcquireTokenAsync(resource, clientId, uri, platformParams);
      return authResult;

In the case of iOS, we don’t need to override/implement any separate method to continue the authentication flow. We should get authResult back whenever the authentication flow completes.

Windows Phone Implementation

PlatformParameters doesn’t need any parameter as such for the Windows Phone app, so we’ll use the following code to allow us to authenticate with AD:

[assembly: Dependency(typeof(ADALForForms.Phone.Helper.Authenticator))]
namespace ADALForForms.Phone.Helper
  class Authenticator : IAuthenticator
    public async Task<AuthenticationResult> Authenticate(string authority, string resource, string clientId, string returnUri)
      var authContext = new AuthenticationContext(authority);
      if (authContext.TokenCache.ReadItems().Any())
        authContext = new AuthenticationContext(authContext.TokenCache.ReadItems().First().Authority);
      var uri = new Uri(returnUri);
      var platformParams = new PlatformParameters();
      var authResult = await authContext.AcquireTokenAsync(resource, clientId, uri, platformParams);
      return authResult;

Just like Android, Windows Phone needs to handle the continuation after login. This can be done by overriding the OnActivated method in the App.xaml.cs file and calling back to the WebAuthenticationBrokerContinuationHelper.

protected override void OnActivated(IActivatedEventArgs args)
  if (args is IWebAuthenticationBrokerContinuationEventArgs)
    WebAuthenticationBrokerContinuationHelper.SetWebAuthenticationBrokerContinuationEventArgs(args as IWebAuthenticationBrokerContinuationEventArgs);

Step 5: Call Authenticate() in the Apps

Now, we need to call the Authenticate method. Let’s add a new HomePage with a button, which should call the Authenticate method on its click event. Before this, let’s declare some variables that are required for authentication. To do so, add a new XAML Page and declare your variables for ADAL.

public static string clientId = "your-client-id";
public static string authority = "";
public static string returnUri = "your-redirct-uri";
private const string graphResourceUri = "";
private AuthenticationResult authResult = null;

Now, we can use the Dependency Service from Xamarin.Forms to locate the Authenticate method in each platform and execute it.

private async void Button_OnClicked(object sender, EventArgs e)
 var auth = DependencyService.Get<IAuthenticator>();
 var data = await auth.Authenticate(authority, graphResourceUri, clientId, returnUri);
 var userName = data.UserInfo.GivenName + " " + data.UserInfo.FamilyName;
 await DisplayAlert("Token", userName, "Ok", "Cancel");

Here, you should have results in the authResult variable. You can use the Access Token from authResult to call any APIs that are secured by Azure Active Directory, e.g., Office 365 and Graph.


Note: ADAL used in this blog post is in preview mode. There may be changes by the time it is released.

You can download the sample created for this post, update your credentials (e.g. Client Id and Redirect URI), and test the app from GitHub

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInEmail this to someone
August 4, 2015

Webinar Recording: Mobile Enterprise Success with Xamarin and Oracle


We’re excited to help our customers build better enterprise apps through our recently announced partnership with Oracle. With this partnership, developers can build native iOS and Android Xamarin apps that quickly integrate with Oracle Mobile Cloud Service (MCS) for robust backend functionality, including push notifications, mobile APIs, storage, analytics, and more.

Watch the recording of the live “Mobile Enterprise Success with Xamarin and Oracle” webinar below to hear leading Forrester Analyst Michael Facemire and Xamarin and Oracle executives discuss our partnership and its impact on enterprise mobility. You’ll also learn about each platform and see a live demo on configuring MCS, building a Xamarin Project, and adding the Xamarin SDK for Oracle Mobile Cloud Service to your projects.

View the presentation slides for this webinar here.

Additional Resources

Visit for more information about our partnership and to download the Xamarin SDK for Oracle Mobile Cloud Service.

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

Bringing Xamarin.Forms Apps to Tablets


When I was developing My Shoppe, a pre-built app template for shops, I only focused on the look and feel for the phone form factor, since I knew that I could add optimizations to the app to spruce it up for tablet owners later. Xamarin.Forms makes it simple to detect what type of device my users are running and provides a few nice helper methods to extend the app for a better tablet experience. Here are a few tips to get you started with optimizing your Xamarin.Forms apps for these larger form factors.


Adding Tablet Support

The first thing to do is ensure that tablet support is enabled for the app, which each platform handles a little bit differently. On iOS, it’s simple to adjust what type of devices an app can be run on: simply click on the properties for the iOS project and under iOS Application is a setting called Devices. This controls the final output of the app for either iPhone/iPod, iPad, or Universal. For My Shoppe, I switched from iPhone/iPod over to Universal to ensure the app has a proper phone and tablet form factor when running on either of the devices instead of a 2x zoom button when running the app on the iPad.


Android handles tablet support a little differently since Android works with pixels in correlation to densities, and any app can be scaled correctly up to a larger screen. There are a few different options that can be added to the Android manifest to filter the app out of Google Play. By default, there are no adjustments that need to get My Shoppe running on tablets correctly.

Optimizing with Device.Idiom

Simply enabling tablet support isn’t enough, and I wanted to finely-tune specific areas of the app to make using My Shoppe on tablets an excellent user experience. Xamarin.Forms provides many different ways to add platform-specific tweaks to layouts through different properties the Device class exposes. You may already be familiar with Device.OS or Device.OnPlatform that can be used to add OS level tweaks, but we can use Device.Idiom to detect if the current device is a phone or tablet. When building a layout for tablet, I often like to switch StackLayouts from vertical to horizontal and display different images when my users are on a tablet. This can be accomplished easily:

if (Device.Idiom == TargetIdiom.Phone)
    MyStack.Orientation = StackOrientation.Vertical;
    HeroImage.Source = ImageSource.FromFile(&quot;hero.jpg&quot;);
    MyStack.Orientation = StackOrientation.Horizontal;
    HeroImage.Source = ImageSource.FromFile(&quot;herotablet.jpg&quot;);

In My Shoppe, I performed these optimizations to take advantage of the additional screen size, and in all of my grid layouts I added additional padding and spacing directly in my XAML:

&lt;Grid VerticalOptions=&quot;FillAndExpand&quot;&gt;
    &lt;OnIdiom x:TypeArguments=&quot;x:Double&quot;
    &lt;OnIdiom x:TypeArguments=&quot;x:Double&quot;
    &lt;OnIdiom x:TypeArguments=&quot;Thickness&quot;
             Phone=&quot;10, 10, 10, 0&quot;
             Tablet=&quot;20, 20, 20, 0&quot; /&gt;
  &lt;!-- Grid Content --&gt;


Leverage MasterDetailPage

Simple platform tweaks are great and can go a long way, but there’s certainly more that can be done to optimize the UX on tablets. I decided that users would see a different page based on the type of device they were using when they tap to see all shop locations. On a phone, the flow wouldn’t change, as a full list of locations would appear and they could drill down to details. On tablets, I decided to navigate to a MasterDetailPage that has a full flyout menu where the locations could be listed and the shop details would be displayed side by side. I accomplished this by re-directing the app to different screens based on the Idiom that was detected. I was still able to leverage all of the existing code in the Store list page by propagating the click event up to the MasterDetailPage to swap out the Detailed information.

Propagate the event

On my original StoresPage I added a new Action that could be used to propagate the event to the MasterDetailPage:

public partial class StoresPage : ContentPage
  public Action&lt;Store&gt; ItemSelected { get; set; }
  public StoresPage ()
    InitializeComponent ();
    //Fill in Binding Context...
    //Handle item selected to navigate to new page or propagate event
    StoreList.ItemSelected += async (sender, e) =&gt;
      if(StoreList.SelectedItem == null)
      var store = e.SelectedItem as Store;
      if (ItemSelected == null)
        await Navigation.PushAsync(new StorePage(store));
        StoreList.SelectedItem = null;

New Tablet Page

I created a new MasterDetailPage that set the StoresPage to the Master and a temporary Detail page asking the user to select a shop. Next, I simply subscribed to the ItemSelected action and swapped out the Detail page:

public class StoresTabletPage : MasterDetailPage
  public StoresTabletPage()
    Title = &quot;Stores&quot;;
    Master = new StoresPage();
    Detail = new ContentPage
      Content = new StackLayout
        VerticalOptions = LayoutOptions.Center,
        HorizontalOptions = LayoutOptions.Center,
        Children =
          new Label { Text = &quot;Select a Shop&quot;, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) }
    //Subscribe to ItemSelected changes and update Detail Page
    ((StoresPage)Master).ItemSelected = (store) =&gt;
      Detail = new StorePage(store);
      if(Device.OS != TargetPlatform.Windows)
        IsPresented = false;
   IsPresented = true;

Updating the Workflow

With the new tablet optimized section of the app ready, all I needed to do was update my Home page to navigate to a different page based on the Idiom:

ButtonFindStore.Clicked += async (sender, e) =&gt;
  if (Device.Idiom == TargetIdiom.Tablet || Device.Idiom == TargetIdiom.Desktop)
    await Navigation.PushAsync(new StoresTabletPage());
    await Navigation.PushAsync(new StoresPage());


Adding Windows Support

My Shoppe also launched on Windows Phone, but Windows Phone is just for phones, so there are no changes that I had to make to that project. Since Xamarin.Forms now supports Windows apps, this is another tablet and desktop form factor that My Shoppe could be extended to. The setup process was just to follow the step-by-step documentation to add the Windows project. After I had the project set up, I only had to install a handful of Plugins for Xamarin, which I use to tap into native capabilities from shared code and add a few Xamarin.Forms custom controls, such as Image Circles. With all the NuGets and project setup in place, My Shoppe was now on Windows desktops and tablets!

Windows Store My Shoppe

Bring Your Xamarin.Forms Apps to Tablets

Optimizations such as these can greatly enhance your users’ experiences in your apps and are very simple implement with the built-in tools included in Xamarin.Forms. Be sure to read through the Working with Platform Tweaks documentation to find additional ways of optimizing your Xamarin.Forms apps, and don’t forget to grab the My Shoppe source code with these tweaks, now available on GitHub.

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInEmail this to someone
July 31, 2015

Building Apps for a Connected World


Building apps for a connected world can be tough; users expect their apps to work all the time, even with a slow (or possibly even no) mobile connection. This week on the Xamarin Podcast, Mike and I share some of our secrets for building connected apps, such as how to speed up network requests, create a pleasant offline experience, and handle exceptional scenarios that may occur.

Subscribe or Download Today

Knowing the latest in .NET, C#, and Xamarin is easier than ever with the Xamarin Podcast, available via iTunes, Stitcher, and SoundCloud. Do you have an interesting story, project, or advice for other .NET mobile developers? If so, we’d love to share it with the Xamarin community! Tweet @pierceboggan or @MikeCodesDotNet to share your blog posts, projects, and anything else you think other mobile developers would find interesting. Be sure to download today’s episode on building apps for a connected world, and don’t forget to subscribe!

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

Close Out Summer with Xamarin Events in August!


Celebrate the end of summer with a bang by joining fellow Xamarin developers at an event near you! This month is jam-packed full of exciting conferences, workshops, seminars, and user group meetups from all corners of the globe!

August Blog

Here’s just a taste of events happening this month:

Xamarin Dev Days – Birmingham Flag of the UK

  • Birmingham, UK: August 2nd
  • Discover what this Xamarin buzz is about with your community in Birmingham

São Paulo .NET Coders br

  • São Paulo, Brazil: August 7th
  • Get started with the Xamarin Platform

Xamarin Workshops & Training Germany

  • Hanover, Germany: August 10 – 15th
  • Five days of extensive training in the world of Xamarin!

DC Mobile .NET Developers Group us

  • Washington, DC: August 11th
  • Xamarin.Forms + Azure Mobile Services with Xamarin MVP, Fabian Williams

DFW Mobile .NET us

  • Dallas/Fort Worth, TX: August 12th
  • Mobile Design Patterns with Xamarin.Forms

Xamarin User Group San Diego us

  • San Diego, CA: August 13th
  • Interactive App Building with Xamarin.Forms

Xamarin Dev Days – Philadelphia us

  • Philadelphia, PA: August 15th
  • Come learn Xamarin awesomeness with your community in Philly

Xamarin Dev Days – New York us

  • New York, NY: August 16th
  • See what Xamarin has to offer with your community in New York

Minnesota Mobile Enterprise us

  • Minneapolis, MN: August 20th
  • Apple Watch Development with Xamarin’s Watch Kit

XHackNight powered by IBM Bluemix & Xamarin in

  • Bangalore, India: August 22 – 23rd
  • LEARN.HACK.WIN: a cross-platform mobile hackathon using Bluemix

Xamarin Dev Days – Madison us

  • Madison, WI: August 22nd
  • Learn how to go mobile with Xamarin with your community in Madison

XLSOFT Japan Japan

  • Tokyo, Japan: August 28th
  • Learn how to manage Android application licensing with Xamarin and Sentinel

Be sure to check out the Xamarin Events Forum for even more Xamarin events, meetups, and presentations happening near you!

Interested in getting a developer group started? We’re here to help! Here’s a tips and tricks guide on staring a developer group, an Introduction to Xamarin slide deck, and, of course, our community sponsorship program to get you started. Also, we love to hear from you, so feel free to send us an email or tweet @XamarinEvents to help spread the word and keep an eye out for events in your neck of the woods!

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInEmail this to someone
July 29, 2015

Xamarin at the Top of the Visionary Quadrant in Gartner’s Magic Quadrant


Gartner logoBased on our vision and ability to execute, we’re honored to be recognized as at the top of the Visionary Quadrant in the recently published 2015 Gartner Magic Quadrant Report for Mobile Application Development Platforms.

Acknowledging the role of mobility as a cornerstone for every business development strategy, Gartner assesses the critical for mobile app development platform market by evaluating the “major vendors to enable enterprise IT developers, architects and mobile development leaders.” We’re thrilled to be recognized for the third year in a row as one of only 20 companies chosen for the report.

Gartner noted a few of our strengths in their assessment, including rapid growth, our wide range of support for the mobile development lifecycle, and the bridge to mobility we provide for traditional enterprise developers:

“Xamarin addresses what has been an underserved segment of the mobile development market — namely, C# developers who want to build native mobile apps without having to learn new languages and tools.”

“In 2014, Xamarin enjoyed strong growth in the enterprise, more than doubling its customers. It attracted high-profile partners such as IBM, SAP, and Oracle and has a growing partner ecosystem.”

We are particularly excited to have achieved this recognition as one of the youngest companies in the quadrant, indicating we’re succeeding in our mission to help you transform your customer relationship and business processes through mobile technology. With exciting new features on the way for Xamarin Platform, Xamarin Test Cloud, and Xamarin Insights, your mobile journey with Xamarin will only continue to get even better.

Visit our enterprise page to learn more about why Xamarin is a visionary in mobile app development.

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInEmail this to someone
July 28, 2015

Amazon Web Services Mobile SDKs for Xamarin Now Available


Amazon Web Services LogoToday, we’re excited to share the launch of the Amazon Web Services (AWS) Mobile SDKs for Xamarin. With these new SDKs, developers can easily connect their high-performance, native Xamarin apps to Amazon’s powerful array of AWS cloud services.

AWS SDK for Xamarin logoAWS platform services provide several solutions, including: identity management through Amazon Cognito Identity, Amazon Cognito Sync, Amazon Simple Storage Service cloud storage, Amazon DynamoDB’s fully managed database, Amazon Mobile Analytics, and Amazon Simple Notification Service for mobile push notifications.

The AWS Mobile SDKs for Xamarin allow you to use a shared C# codebase to connect your native Xamarin iOS and Android apps to any of these AWS services. For example, you can use Amazon Cognito Cloud Sync to synchronize app states between devices for a seamless, cross-device experience and use Amazon S3’s cloud storage for easy access to critical documents and content.

Integrating the AWS Mobile SDKs for Xamarin into your mobile apps is simple.

Getting Started

This example will show you how to get started with Amazon Cognito Cloud Sync:
AWS Cognito SDK

In your app, you will need to initialize a CognitoSyncManager and open a dataset using the Identity Pool ID and Region Endpoint of the pool you just created:

public Dataset GetDataset ()
	// Login and open/create the dataset
	var credentials = new CognitoAWSCredentials ("identity-pool-id", RegionEndpoint.USEast1);
	// Optional: Add credential login to associate data to a user
	// credentials.AddLogin ("", "FB_AUTH_TOKEN");
	var syncManager = new CognitoSyncManager (credentials,
new AmazonCognitoSyncConfig { RemoteEndpoint = RegionEndpoint.USEast1 });
	var dataset = syncManager.OpenOrCreateDataset ("TODO_LIST");
	return dataset;

If you would like your dataset associated to a particular user, enabling the user to share the same data across devices and platforms, you will need to set up an identity provider. Cognito supports Facebook, Google+, Twitter, Amazon, OpenID, or a custom Developer Authenticated Identity.

If you use Facebook authentication, you can use the Facebook Components to authenticate your users after you’ve configured your App ID in the Cognito portal, and then add the authentication token to your credentials before opening your dataset:

credentials.AddLogin ("", "FB_AUTH_TOKEN");

You can store any information you’d like in your dataset by specifying an ID and an arbitrary value (in this case a JSON string). After you call the async Sychronize() method, your data will be pushed to the cloud:

public async Task CreateTodoItem (string title)
	var dataset = GetDataset ();
	// Create a new todo list item
	var todoItem = new TodoItem ("Pick up some milk");
	// Serialize the object to JSON and put it in the dataset
	dataset.Put (todoItem.Id, JsonConvert.SerializeObject (todoItem));
	// Synchronize changes to the cloud
	await dataset.SynchronizeAsync ();

You can also easily fetch all of the items in your dataset from the cloud on any device:

public async Task<IEnumerable<TodoItem>> GetTodoItems ()
	var dataset = GetDataset ();
	// Synchronize any changes
	await dataset.SynchronizeAsync ();
	// Deserialize the records' values from the dataset
	return dataset.Records.Select (r =>
                JsonConvert.DeserializeObject<TodoItem> (r.Value));

AWS and Xamarin take the hard work out of adding a complex backend to your apps, giving you a flexible, scalable way to go mobile. Be sure to check out all of the AWS SDK Components in the Component Store today!

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

Join Xamarin at AnDevCon 2015 in Boston


Join Xamarin in Boston, MA from July 30-31 for AnDevCon 2015, the technical conference for software developers and engineers building Android apps. Key members from the Xamarin team will be available to discuss your apps and projects and show you what’s new across our products.

AnDevCon 2015 Boston Banner

We’re excited to give AnDevCon 2015 attendees a close up look at Xamarin Test Cloud, which we recently announced will be getting support for Appium and its multiple language bindings, including Java, JavaScript, Python, and PHP. You’re invited to join our early access program, and we’ll have members from our Xamarin Test Cloud team onsite at the conference to answer any of your questions.

Come visit us at booth #803 and say hello if you’re at the conference — we look forward to seeing you in Boston!

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

More Awesome Content from Our Community


Xamarin developers not only build amazing iOS and Android apps in C#, but love contributing to the Xamarin community through blog posts, components, plugins, and podcasts. The links below will take you to some of favorites over the past few weeks:


Yet Another Podcast with Jesse Liberty

James Montemagno and Jesse Liberty discuss all things Xamarin.

  • Yet Another Podcast – James Montemagno joins Jesse Liberty discuss all things Xamarin, including My Shoppe, Moments, and Xamarin Dev Days.

Great Blog Posts

Awesome Xamarin.Forms Blog Posts

Adam Wolf’s card UI with a drop shadow using Xamarin.Forms.

Thanks to these developers for sharing their Xamarin knowledge with the rest of the developer community. If you have an article or blog post related to Xamarin development that you would like to share, please let us know by tweeting @XamarinHQ and it may be featured in an upcoming community content roundup.

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

Build Your Own Messaging App in XAML


One of the most popular features of Xamarin.Forms is the ability to use your existing XAML experience to build UIs for iOS, Android and Windows Phone. Moments, a Snapchat clone built with Xamarin.Forms and Microsoft Azure, originally made use of the C# API for creating user interfaces. Today, I’m happy to announce that Moments has been expanded to include a XAML implementation as well, so you can build your own Snapchat clone in XAML today!

Moments, a Snapchat clone built with Xamarin.Forms and Azure.

Build Cross Platform UIs in XAML

If you are coming from a Windows background, Xamarin.Forms XAML will feel right at home! If you aren’t, there are still plenty of great reasons to build your user interface using XAML.


XAML is often more succinct and readable than the equivalent code in C#. This is especially true when building complex view hierarchies with multiple layouts. Additionally, the parent-child hierarchy inherent in XML allows XAML to mimic the hierarchy of user interface objects with greater visual clarity.

Separation of Concerns

Rather than having an entire page represented in one file, XAML allows you to clearly separate views from the accompanying logic associated with the view, thus making your application more modular.

MVVM Data Binding & Commands

The Model-View-ViewModel (MVVM) architectural pattern is very common in mobile development today – and for good reason. Traditionally, MVVM allows you to further enforce separation of concerns by separating the user interface from the data, with a bridge called a view model. Typically, mobile developers can share the model and view model with all target platforms, while writing the view for each individual platform. With Xamarin.Forms, everything can be shared, including the view. XAML makes using the MVVM pattern easy through data binding and commands, which allow your view and view model to communicate with ease.

Build Your Own Snapchat Clone Today

Moments is a great sample app for seeing everything Xamarin.Forms has to offer. If you’ve ever wondered how to use custom controls from XAML, use markup extensions, implement styling, or enforce the MVVM architectural pattern through data binding and commands, Moments is the sample app for you. Moments is completely open-source and freely available under the MIT license, so building your own Snapchat clone based on Moments is easy. Follow the steps listed here, and you’ll be sending selfies to all your buddies in a matter of minutes!

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