Follow me on Twitter at
FYI, I'm blogging most of my stuff over at More Wally now.
You might want to add my rss feed to your reader at:
UIPicker in the iPhone with MonoTouch - Wallace B. McClure

Wallace B. McClure

All About Wally McClure - The musings of Wallym on Web, HTML5, Mobile, Xamarin.iOS, Xamarin.Android, and Windows Azure.


Visual Studio Magazine Column Personal Blog


Book Authors




Georgia Tech Bloggers



UIPicker in the iPhone with MonoTouch


The UIPicker is visually different than the drop down listbox that most .NET developers are familiar, however, it is designed to perform the same type of function.  It allows users to select from a fixed set of data isntead of typing in data in a text box.  Programming with it is fairly simple.  Inherit from the UIPickerViewModel class and then bind the data.

Here's the class:

using System;

using MonoTouch;

using MonoTouch.UIKit;

using MonoTouch.Foundation;


namespace OpenUrl




public class ProtocolData : UIPickerViewModel



public static string[] protocols = new string[]


"http://", "tel:","", "sms:",



public string[] protocolNames = new string[]


"Web", "Phone Call", "Google Maps", "SMS", "Email"    


AppDelegate ad;

public ProtocolData(AppDelegate pad){

ad = pad;


public override int GetComponentCount(UIPickerView uipv)




public override int GetRowsInComponent( UIPickerView uipv, int comp)


//each component has its own count.

int rows = protocols.Length;



public override string GetTitle(UIPickerView uipv, int row, int comp)


//each component would get its own title.

string output = protocolNames[row];



public override void Selected(UIPickerView uipv, int row, int comp)


ad.SelectedRow = row;


public override float GetComponentWidth(UIPickerView uipv, int comp){



public override float GetRowHeight(UIPickerView uipv, int comp){





And then you bind data doing something like this:

ProtocolData protocolDataSource = new ProtocolData(this);

ProtocolSelection.Model = protocolDataSource;

And there you go, you now have a UIPicker with a list of data.

Want to know more about developing with the iPhone?  Check out my Wrox Blox eBook on developing applications with MonoTouch for the iPhone/iPod touch for .NET/C# developers


Jim Wilson said:

Well done--worked great! Nice eBook by the way. I hope there's another edition that adds stuff like this in it.

# January 12, 2010 2:03 PM