Thank you for the reply.

I did a little more reading on other objects, and did exactly what you said,
I subclassed the existing DateElement, added a reference to the SSE object
that Im changing, and hooked up the event... it looked a little something
like this:

sseFromDate = new StyledStringElement("From: ", "",
UITableViewCellStyle.Value2);
myDateElement dateFrom = new myDateElement("Select From Date",
DateTime.Today, sseFromDate);

the subclassed myDateElement: 

public class myDateElement : DateTimeElement {
                
                UIDatePicker _picker;
                StyledStringElement _sse;
                
                public myDateElement (string caption, DateTime date, 
StyledStringElement
sse) : base (caption, date)
                {
                        fmt.DateStyle = NSDateFormatterStyle.Medium;
                        
                        _sse = new 
StyledStringElement("","",UITableViewCellStyle.Default);
                        
                        _sse = sse;
                        
                        _picker = base.CreatePicker ();
                        _picker.Mode = UIDatePickerMode.Date;
                }
                
                public override string FormatDate (DateTime dt)
                {
                        return fmt.ToString (dt);
                }
                
                public override UIDatePicker CreatePicker ()
                {
                        var picker = base.CreatePicker ();
                        picker.Mode = UIDatePickerMode.Date;
                        picker.ValueChanged += HandlePickerValueChanged;
                        
                        _picker = picker;
                        return picker;
                }

                void HandlePickerValueChanged (object sender, EventArgs e)
                {
                        
                         var _dateTime = new DateTime();
                        
                         _dateTime = NSDateToDateTime(_picker.Date);
                        _sse.Value = FormatDate (_dateTime);
                         
                }
                
                public static DateTime 
NSDateToDateTime(MonoTouch.Foundation.NSDate date)
                {
                    return (new
DateTime(2001,1,1,0,0,0)).AddSeconds(date.SecondsSinceReferenceDate);
                }
                
                public static MonoTouch.Foundation.NSDate 
DateTimeToNSDate(DateTime date)
                {
                    return
MonoTouch.Foundation.NSDate.FromTimeIntervalSinceReferenceDate((date-(new
DateTime(2001,1,1,0,0,0))).TotalSeconds);
                }
                
        }

-----
UI Developer/Graphic Artist
--
View this message in context: 
http://monotouch.2284126.n4.nabble.com/MonoTouch-Dialog-Help-Needed-how-to-update-StyledStringElement-with-ValueChange-from-DateElement-tp4330795p4331415.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to