Expandable Date Element for MonoTouch.Dialog

A while back, I asked if anyone else had done this:

UPDATE: My apologies to Kraig Spear - he was the one who originally provided the code. Sorry for mis-crediting it! I think I had some similar stuff from Gerry High around the same time.

I had few replies, and I think I got a (mostly) working version from Kraig Spear. Glenn Stephens promted me about it today, tho, and here's a Gist with the code. I use it Trip Wallet to edit the dates, tho I need to migrate it to my other apps, too.

And you use it like:

var tripStartElement = new StyledExpandableDateElement("Start", startDate, UIDatePickerMode.Date, root, section);
tripStartElement.ValueChanged += (DateTime newDate) =>
{
	tripDayCountElement.Value = FormatDayCount(tripStartElement.Value, tripEndElement.Value);
};
			
var tripEndElement = new StyledExpandableDateElement("End", endDate, UIDatePickerMode.Date, root, section);
tripEndElement.ValueChanged += (DateTime newDate) =>
{
	tripDayCountElement.Value = FormatDayCount(tripStartElement.Value, tripEndElement.Value);
};

It is, as far as I know, fully timezone aware (especially fun for a travel app when I live in GMT+13!), so the date you get back has al the right bits set.

Enjoy! Thanks Kraig for the code, and Glenn for the prompt to release it.

Nic Wise

Nic Wise

Auckland, NZ