Created
June 8, 2012 06:39
-
-
Save conceptdev/2893977 to your computer and use it in GitHub Desktop.
PickerView01
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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