migueldeicaza/MonoTouch.Dialog — Issue #99: Add Event Handler to DateTimeElement
Author: ogazitt
Created: 2012-02-07 07:11:17+00:00
State: open

It would sure be nice if the Tapped event handler (from the StringElement base class) were invoked when the DatePicker gets dismissed.

Currently, since the Selected method is overridden to create the datepicker, there is no place where that event handler gets invoked.

The scenario is where I changed a date using the datepicker and now I want some side-effect to happen (e.g. another UI element gets updated, a web service call is made, etc).

This would be easy to do in Element.cs:1708:

public override void ViewWillDisappear (bool animated)
{
base.ViewWillDisappear (animated);
container.DateValue = container.datePicker.Date;
// new code below
if (Tapped != null) Tapped();
}

Without this fix, it looks like I need to create custom DateTimeElement, DateElement, TimeElement classes which all copy the existing code verbatim (since I can't get at the underlying UIViewController to override ViewWillDisappear myself)... all for the one line of code above :-(

Thanks!

Omri.