Saturday, 14 May 2016

Xamarin.Forms Workbooks

As explained in the last post, it's easy to add Nuget packages to Xamarin Workbooks. My immediate reaction to this news was "I want to use Xamarin.Forms!" Unfortunately it's not immediately obvious how to get Xamarin.Forms into a Workbook... so here are the steps (for an iOS Workbook):

1. Add the Xamarin.Forms nuget (and reference the platform)

When you add the Xamarin.Forms Nuget, four assemblies will be referenced (including the iOS Platform assembly for Xamarin.Forms). The using statements need to be added too - don't forget to add the Xamarin.Forms.Platform.iOS namespace:

2. Create a Page and App as usual

In both classes it's a good idea to create public properties for elements you want to manipulate in the workbook.

This allows those controls to be referenced later in the workbook...

3. Hack the FormsAppDelegate

The biggest hurdle to getting Xamarin.Forms to run is that in a normal iOS app, the AppDelegate must be a subclass of FormsApplicationDelegate to wire up various bits of Xamarin.Forms. Peeking into the open-source, the key thing we need to do is set the RootViewController... the following code does the initialization we need to get a Workbook running:

WARNING: obviously this approach misses some of the other code implemented in FormsApplicationDelegate so some things might not work as expected. This is a bit of a hack :)

4. Run It

The public properties on the App and Page classes mean the workbook can manipulate those elements to demonstrate various Xamarin.Forms capabilities.

Try it out with the WorkbookFormsTest workbook:

Check out the more complex ListView1 workbook too:

p.s. the irony of included screenshots of code is not lost on me - but hey, it's actually a good reason to download and us Xamarin Workbooks to try these samples out :D

Xamarin Workbooks with Nugets

Xamarin Workbooks are getting better and better (check out the intro to Workbooks if you don't know what I'm talking about).

Nuget packages can now be added, meaning you can teach or demo almost anything in a Workbook :)

In the Workbook app, choose File > Add Package... to open the Nuget package explorer:

Then search for the Nuget and add to the workbook:

Try out this Json.NET Workbook example to see how it works

Coming up next - adding the Xamarin.Forms nuget!

p.s. for a video demo of Nugets in Workbooks, check out this community contribution on

Monday, 25 April 2016

Xamarin Evolve 5k

Update: thanks everyone who ran!

There's been a tradition for the more energetic attendees to do a morning 5k run during Xamarin Evolve - and 2016 will be no different! Xamarins have been out training most mornings, and we look forward to meeting and running with our customers. It's a FUN run, not a race - if you've got your gear and can complete the distance, please join us! Follow @conceptdev for twitter updates.

Date: Wednesday 27th (first day of conference, before the keynote)
Time: 6:15am
Place: outside Hyatt reception (near the flagpoles)

The Course

We'll run a flat 5km (3.2 mile) loop anti-clockwise around the conference center and surrounds:

It'll be early morning so traffic should be light (based on the past few days), however there are a couple of road crossings and safety will be the priority over speed. This is what the meeting place looks like at 6:15am:

For the speedsters, hang around at the end if possible to celebrate with everyone, get a group photo, and ensure you get mini-hack credit for completing the run!

Monday, 4 April 2016

Introducing Xamarin Workbooks

The first public demonstration of Xamarin's new Workbooks idea was Miguel de Icaza's //build 2016 talk "Mobile First" (although he first wrote about it back in February). In his talk, Miguel demonstrates a new take on interactive documentation in which a Markdown-formatted file can live-execute C# code-fenced blocks; not just in-line but also in an iOS or Android simulator.

This opens up a great opportunity to write and share interactive documentation that not only describes an API or feature, but shows it in action. Further, it's easy to write, being based on the well-known Markdown format.

Give it a try!

You can now try Workbooks for yourself! The editor can be downloaded here, and there is some Workbook documentation on the Xamarin developer portal.

I've thrown together a few very simple ideas on github:

See Miguel's talk (if you didn't already) for a really cool demo.

Some Notes

  1. They're written in Markdown, but with a .workbook file extension.
  2. Each file begins with a small JSON-formatted metadata section. The editor will add this for you.
  3. C# code inside triple-backtick code fences will be executed when the file is viewed in the Workbooks editor. 
There's sure to be other resources popping up now that the project preview is publicly available -- Ben Bishop's video is the first community resource I've seen. Can't wait to see what everyone creates with it!

Tuesday, 29 September 2015

iOS 9-ify your Xamarin.Forms App

It's not just regular Xamarin.iOS apps that can implement fancy iOS 9 features :) Check out the quick hacks I did to this Restaurant Guide Xamarin.Forms sample to add iOS 9 features:

Mostly using the magic of Dependency Service I added:

No special work was required to get the app running with iPad Multitasking, other than to ensure there was a Storyboard (or XIB) Launchscreen.

Finally, I added the Application Transport Security "opt-out" tags to the Info.plist file, so that the links to all the different restaurants would work in the WebView control.

Download the code from github to try for yourself!

p.s. Ignore the fact that this sample uses Razor templates to generate the restaurant detail view. That is merely a coincidence - this existing Xamarin.Forms sample was the most appropriate to add iOS 9 features to. iOS 9 features can be added to any Xamarin.Forms app, whether it displays data with XAML, C#, or in a Razor HTML template ;)

Sunday, 27 September 2015

iOS 9-ify your Xamarin App

With the iPhone 6s models now available, it's possible to build and test all the great new features of iOS 9 with Xamarin. To demonstrate, I've tried to squeeze as many iOS 9 features as possible into one sample: To9o app (that's "Todo" but with a "9" :-) The c# code is on github and screenshots of each iOS 9 feature are shown below.

3D Touch

3D Touch can used a few different ways, but requires an iPhone 6s to test (the Simulator doesn't support 3D Touch). I started by adding these two:

Multitasking for iPad

If the app can resize its UI appropriately, it should work fine for multi-tasking!


The "Todo" app doesn't traditionally need an interface to the Contacts list, but I added it just to give this new API a try :)

New Search APIs

The new search APIs let you expose content to search and Siri. I've added both:
Notice the Back to Search button in the navigation bar.


This new layout option makes it much easier to build screens that 'scale', and also makes it even easier to support RTL languages (see below).
* Note: currently UIStackViews must be drawn using Xamarin's Xcode integration, but the built-in Xamarin iOS Designer will support them soon!

Collection View Changes

The main Todo list is a UICollectionView rather than a table, so it can demonstrate how easy it now is to re-order items with two simple methods added in code.

Right-to-Left Language Support

The entire app can now automatically flip (including UINavigationController animations) when displaying RTL languages like Arabic and Hebrew (note: machine translation used for example, apologies for any inaccuracies).


This new API makes it easy to implement an in-app web browsing experience with a line or two of code. I've used it just for an "About" window.

All these improvements are explained in Xamarin's iOS 9 docs, and the code is available to review. It is still a work-in-progress so check back for more updates. 

Wednesday, 18 March 2015

Microsoft Band SDK + Xamarin

Band-fans were happy to see Microsoft release their Java Android SDK for Microsoft Band a few weeks ago, and their Objective-C iOS SDK this week. Xamarin was then able to almost immediately release the Microsoft Band SDK component for iOS and Android, giving you the same functionality but entirely in C# for all three mobile platforms...

I decided to give it a try, converting my "magic eight ball" apps for Xamarin.Forms and Apple Watch to the Band. The idea is: you shake your wrist and the "prediction" appears on the Band!

It works because there is an Android app running on the paired phone, using the Band SDK. The app is tracking the Band's accelerometer, and using the readings to decide when you've shaken your wrist a couple of times.

When the shake-detection is triggered, the app picks a random number, pushes a new Tile onto the Band (if it doesn't already exist), and then sends a message for the tile with a random "prediction".

The Android app is simple, it contains only a Connect button to connect to the Band, and a Vibrate button to test the connection (plus a label that displays the "prediction" text that is sent to the Band).

The code for this Android sample is available on github, hopefully I'll get the iOS version running soon.

If you want to get more info about developing for the Band, check out Matt's detailed blogpost with code.

Finally, Microsoft built a quite detailed Android app that demonstrates all aspects of their SDK, and Matt did an amazing job of porting it to Xamarin - check that out too!

Saturday, 21 February 2015

Apple Watch Kit round-up

It's Saturday, a good excuse for a 'fun' post. Here's a little collection of tidbits about the Apple Watch...

Apple: Watch Kit - if you're thinking of developing for the platform, might as well start at the source :)

Wareable: The best Apple Watch apps... - some great screenshots of apps already being built, including Clear, BMW, and Nike. It's interesting to see the UI design approach being taken by different developers. Check out the similar list on

WatchAware: Watch Apps - great catalog of watch app demos.

FastCompany: How the Apple Watch will work... - a couple of thoughts on app design, and screenshots of Todoist.

eleks labs' unofficial Tesla app - more design thoughts and prototype video (unofficial development, not affiliated with Tesla)..

Daring Fireball: On the Pricing of the Apple Watch - so yeah, "starting at $349" sounds like it's going to be the understatement of the year.

WatchKit FAQ - awesome collection of questions and answers (and cute watch drawings too).

MartianCraft: Designing for the Apple Watch with Briefs - even if you don't use the tool (which looks great) this is a lovely post on Watch app design.

Five Minute Watch Kit - good collection of blog posts.

If that's got you interested in building apps for the Apple Watch, it's time to check out Xamarin's Watch Kit Preview and how to get started (inc video) and my first watch app.

I've also got a couple of samples, including Magic 8 Ball, Calculator, Insta, and Todo for you to try.

^ watch frame screenshots generated with Bezel thanks to the fine folks at infinitapps.