0

Is there any way to grab the value changed event on a MonoTouch Dialog DateElement? The Tapped event never is hit, and the datePicker property is null so I cannot hook onto the ValueChanged event. Any ideas?

I want to set values of other fields when the date changes and I can't find a way to do this.

Dylan
  • 1,919
  • 3
  • 27
  • 51

1 Answers1

0

I don't know if this is the best way to achieve what you want to do, but you can extend the DateElement to trigger events when the value is selected.

Here is an example DateElement:

public class CustomDateElement : DateElement
{
    public event System.Action<CustomDateElement> DateChanged;

    public CustomDateElement(string caption, DateTime date) : base(caption, date) {}

    public override string FormatDate (DateTime dt)
    {
        if (DateChanged != null)
            DateChanged(this, dt);

        return base.FormatDate (dt);
    }
}

And here is an example of how to use the new CustomDateElement:

var dateElement = new CustomDateElement ("Due Date", model.Birthday);

dateElement.DateChanged += (obj) => {
    Console.WriteLine(obj.DateValue);
};
Jamil Geor
  • 337
  • 2
  • 5
  • I've since looked through MonotTouch.Dialog source on GitHub, there is a new DateSelected event that you can now use. But doesn't seem to be working 100% yet. – Jamil Geor Mar 24 '12 at 02:22