locked
Date picker/Time picker RRS feed

  • Question

  • Hi,

     I'm using both the date picker and time picker within Silverlight. I would like the date picker on load to show the current date (today's date) instead of showing <m/d/yyyy>.

    For the Time picker, I would like to set my own time on initial load (ex. always loads with 1:00 pm) and than allow the user to change it afterwards.

     Does anyone know how to do this?

    Thanks 

     

    Tuesday, May 18, 2010 9:25 AM

Answers

  •  For date picker set the selected date property

    <controls:DatePicker Margin="0,178,0,0" VerticalAlignment="Top" SelectedDate="3/1/2010"/>

     Time picker set the value property

    <inputToolkit:TimePicker Value="4:00 Pm" Height="24" Margin="0,178,0,0" VerticalAlignment="Top" Width="148"/>

     

    Or you can set them from code behind, like in their load function for example.

    Tuesday, May 18, 2010 9:47 AM
  • Nevermind,

     Just needed to modify it a bit,

    datePick.SelectedDate=date.now

    Working fine now thanks.

    Tuesday, May 18, 2010 2:52 PM

All replies

  •  For date picker set the selected date property

    <controls:DatePicker Margin="0,178,0,0" VerticalAlignment="Top" SelectedDate="3/1/2010"/>

     Time picker set the value property

    <inputToolkit:TimePicker Value="4:00 Pm" Height="24" Margin="0,178,0,0" VerticalAlignment="Top" Width="148"/>

     

    Or you can set them from code behind, like in their load function for example.

    Tuesday, May 18, 2010 9:47 AM
  • Hi,

    Thanks, that was what I wanted for the time picker, however for the date picker, I don't want to set it at a specific date. I want to have it change based on the current date or whatever the computer calander states. For example, today would be 5/18/2010 and when they run it tomorrow it would show up as 5/19/2010 etc.

    Tuesday, May 18, 2010 10:01 AM
  •  Set the selectedDate to this:

    DateTime.Now.Day.ToString(CultureInfo.CurrentUICulture);

     

    Tuesday, May 18, 2010 10:14 AM
  •  Here is also another alternative:

    http://forums.silverlight.net/forums/p/142256/317457.aspx

    Tuesday, May 18, 2010 10:15 AM
  • Hey,

    I tried both ways and doesn't seem to be working for me.

    DateTime.Now.Day.ToString(CultureInfo.CurrentUICulture)  <- How do I bind this to my date picker? My date picker is named x:name=datePick

    So I tried, datePick= DateTime.Now.Day.ToString(CultureInfo.CurrentUICulture), but that throws an exception.

     In the other thread, xmlns:sys="clr-namespace:SilverlightApplication32" gives me an error, saying it can't be found. Tried looking for it, but can't seem to find it.

    Any ideas?

    Thanks

    Tuesday, May 18, 2010 2:34 PM
  • Nevermind,

     Just needed to modify it a bit,

    datePick.SelectedDate=date.now

    Working fine now thanks.

    Tuesday, May 18, 2010 2:52 PM