2 votes
fixed
TimePicker does not show initial Value set in Xaml

Description

 
When setting a value in xaml, the TimePicker does not show it in the TextBox, as reported here: http://silverlight.net/forums/t/83044.aspx

Suggested workaround:
Subscribe to the loaded event of your TimePicker and use this code in the eventhandler:

1 private void TimePicker_Loaded(object sender, RoutedEventArgs e)
2 {
3 Dispatcher.BeginInvoke(() =>
4 {
5 DateTime? value = tp.Value;
6
7 tp.Value = null;
8 tp.Value = value;
9 });
10 }

File Attachments


No files are attached


Comments

most recent at top (show oldest at top)
nikryden wrote Apr 15 2009 at 8:10 AM
'If u use timepicker in a datagrid and need to Invoke unnown number of timepickers you can do somthig like this.

Dim tmpSender(0) As TimePicker
Dim tmpI As Integer = -1
Private Sub beginInvoke()
Dim dt = tmpSender(tmpI).Value
tmpSender(tmpI).Value = Nothing
tmpSender(tmpI).Value = dt
tmpI -= 1
End Sub

Private Sub TimePicker_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
tmpI += 1
ReDim Preserve tmpSender(tmpI)
tmpSender(tmpI) = CType(sender, TimePicker)
tmpSender(tmpI).Dispatcher.BeginInvoke(AddressOf beginInvoke)
End Sub
End Class

cmhoward wrote Apr 7 2009 at 3:04 PM
Same behaviour experienced when setting the value from code behind

nikryden wrote Apr 3 2009 at 2:42 PM
Suggested workaround in VB.NET

Private Sub TimePicker_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
Dispatcher.BeginInvoke(AddressOf BeginInvoke)
End Sub

Private Sub BeginInvoke()
Dim dt = tp.Value
tp.Value = Nothing
tp.Value = dt
End Sub

Updating...
© 2006-2010 Microsoft | About CodePlex | Privacy Statement | Terms of Use | Code of Conduct | Advertise With Us | Version 2010.1.12.16187