Skip to content

Instantly share code, notes, and snippets.

@conceptdev
Created June 8, 2012 06:39
Show Gist options
  • Save conceptdev/2893977 to your computer and use it in GitHub Desktop.
Save conceptdev/2893977 to your computer and use it in GitHub Desktop.
PickerView01
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace PickerView01
{
public class Application
{
static void Main (string[] args)
{
UIApplication.Main (args);
}
}
/// <summary>
/// PickerView01
/// simple list example
/// </summary>
public partial class AppDelegate : UIApplicationDelegate
{
ListBoxModel lbm; // ADDED
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
lbm = new ListBoxModel (this); // ADDED
ListBox.Model = lbm; // UPDATED
ListBox.ShowSelectionIndicator = true;
window.MakeKeyAndVisible ();
return true;
}
class ListBoxModel : UIPickerViewModel
{
AppDelegate app;
List<string> data;
public ListBoxModel (AppDelegate appDelegate)
{
app = appDelegate;
data = new List<string> { "Cirrus", "Stratus", "Cumulus", "Fog" };
}
public override int GetComponentCount (UIPickerView picker)
{
return 1;
}
public override int GetRowsInComponent (UIPickerView picker, int component)
{
return data.Count;
}
public override string GetTitle (UIPickerView picker, int row, int component)
{
return data[row];
}
public override void Selected (UIPickerView picker, int row, int component)
{
app.DisplayText.Text = "You selected " + data[row];
}
}
public override void OnActivated (UIApplication application)
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment