Xamarin Studio Tips & Tricks


I live inside Xamarin Studio for most of my coding adventures. I'm pretty happy there, but there are some small things I have learned that help with productivity and feeling more comfortable.


Your //TODO: comments don't have to get lost. You can find them all in a list via the Xamarin Studio -> View -> Pads -> Tasks window. Double-click them to jump right to the code line.

Change the Tasks pad to show "User Tasks" and you can create your own to-do list with a checkbox for when it's complete.

Bonus tip: You can create custom comment keywords in the Xamarin Studio -> Preferences -> Tasks window.

Markers and Rulers

There are a few productivity gems in here that I have recently come to enjoy. Open the Xamarin Studio -> Preferences -> Markers and Rulers menu. Then, try out these settings by checking the boxes:

Some of my favorites that I recently found were available are the "Highlight current line" and "Show indentation guides".

Code Templates

AKA "Snippets". Create and edit them in Xamarin Studio -> Preferences -> Code Templates. Create your customizable areas with this format: $name$. Then, you can click on it and customize the default options. Here is one that I use for quickly scaffolding bindable properties in Xamarin.Forms:

public static readonly BindableProperty $name$Property =
	BindableProperty.Create<$view$,$type$>(p => p.$name$, default($type$));
public $type$ $name$
    get { return ($type$)GetValue($name$Property); }
    set { SetValue($name$Property, value); }

Source Analysis

This does static analysis on your code and suggests some refactorings when possible. It'll also catch some mistaks or missed references, etc. It's not Resharper, but I find it more useful than not. Turn it on via the Preferences -> Source Anaylsis menu.

Directory Namespaces

If you would prefer that each code file you add to a subdirectory is created in a namespace that matches, you'll have to enable this in the Preferences -> .NET Naming Policies menu. Check the "Associate namespaces with directory names" box. You have some additional options in there you can customize.

Custom Breakpoints

I find it useful sometimes to create a breakpoint that is hit when any System.Exception is thrown. It's useful for catching errors that might be swallowed or hidden for some other reason. You can do this via the Xamarin Studio View -> Debug Windows -> Breakpoints window. In this window, click the "New Exception Catchpoint" button. Then, add System.Exception in the "When an exception is thrown" textbox.

Edit the Project File

You can edit the project file of a project right inside Xamarin Studio. Right-click on a project and go to the Tools -> Edit File menu. This opens the project file in a text editor. You can quickly make changes in there and then save to reload the project.

Go to File

This is a searching shortcut to quickly open/search for a specific file by name. Press CMD+SHIFT+D on your Mac while in Xamarin Studio. This jumps you up to the search bar in the upper right with the filter file:. Now type in a file name to search for and press enter to jump right to it.

Separate Solution Files

This is not a feature of Xamarin Studio but more of a "best practice" that I like to use. If you a solution that may contain projects that only load on Windows (WPF, WP, etc) you might consider making a separate solution (.sln) file for working in Xamarin Studio on a Mac. XS does a decent job of just not loading incompatible projects with a cute icon to let you know why. You might find it handy to just not have all this loading. Create a new solution file via Xamarin Studio -> File -> New Solution -> Miscellaneous -> Blank Solution and name it something like MyProject.XamarinStudio.sln. Then, save this where you have your other .sln file. Add only the projects you need for solution now. Right-click the solution -> Add -> Add Existing Project. Rinse/Repeat.

If you know of something else that's helped you, I'd love to hear it!