Skip to content

The coolest tool that you are not yet using (Xamarin edition)

Have you played with Xamarin Sketches yet?  Sketches was announced at Evolve back in October and is available in Xamarin Studio on OS X.  It gives you a real time coding environment and lets you interactively try code out without having to go through a code/compile/deploy cycle.

I was asked by a co-worker on how to display a glyph in a button on iOS to indicate that a popup list was available.  I wanted to display an upside down caret, a triangle if you will, as part of the caption to a button.   Basically, I wanted the text to look more or less like this

Happy ▼

And thanks to Unicode, we have that symbol available to us.  Before telling my colleague to just slap a character to the end of the button caption, I wanted to test for myself that it would display correctly on an iPhone.

Normally, I would just create a new singleview iPhone project and slap a label on it.  I would then fire up the simulator and see how it looked.   That way works, but today I decided to take a shortcut and try Xamarin Sketches.

Xamarin Sketches lets you type in code and it compiles and runs it as you type.  It provides an isolated sandbox to try out some code and basically fool around before you put that code into a project.

It’s similar to Xcode Playground, except being Xamarin, it does cross-platform.  You can interactively test code for iOS and Android,   You can’t do everything in Sketch, you can’t create classes or use anonymous types.

For what I needed to try, Sketches would work just fine.  I created a new Sketch and set the platform to iOS and the toolkit to UIKit.  It can do Xamarin.Forms, but in this case I wanted to test for Xamarin.iOS code.

I created a string variable with some text and included the unicode escape sequence “\u25BE”.  That is code for something called “BLACK DOWN-POINTING TRIANGLE”.  I then created a UILabel and set the text to my string variable.  That was enough to generate the proof of concept that I needed:

Xamarin Sketches (click the picture to embiggen it)

This code was extremely simple, but it was all I needed to verify that the unicode sequence would work correctly.  I was able to do that and help out a co-worker without getting out of the cod that I was working on.

You can do more complicated things in Sketches.  During the Evolve Keynote, Miguel de Icaza wrote a simple little iOS game in Sketches:

And then did a simple Xamarin.Forms apps: 

This only works with Xamarin Studio on OS X, it’s not available in Xamrin Studio for Windows or with the Visual Studio Plugin.  That’s not really a roadblock for me, if you are doing any iOS work, you pretty much have to have access to a Mac.  If you are doing iOS work with Xamarin, you are missing out on a handy tool if you are not using Sketches.