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 brax.tv

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!