This is a migrated thread and some comments may be shown as answers.

Binding Errors with Pickers

3 Answers 204 Views
DatePicker for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Brendan
Top achievements
Rank 1
Brendan asked on 22 Jul 2012, 12:55 PM
OS: Windows 8 RP
RAD Version: 2012.1.712.0
Repro: https://github.com/shiftkey/radcontrol-repros/tree/master/DatePickerBinding

Using the DatePicker in a project and I see binding exceptions when I bind to a DateTime property:

1) Set the DataContext without populating the value:

Error: Converter failed to convert value of type 'System.DateTime' to type 'DateTime>'; BindingExpression: Path='DateTime' DataItem='DatePickerBinding.ShellViewModel, DatePickerBinding, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'; target element is 'Telerik.UI.Xaml.Controls.RadDatePicker' (Name='null'); target property is 'Value' (type 'DateTime>'). 

2) Following on from scenario 1), use the RadDatePicker to set the date:

Error: Cannot save value from target back to source. BindingExpression: Path='DateTime' DataItem='DatePickerBinding.ShellViewModel, DatePickerBinding, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'; target element is 'Telerik.UI.Xaml.Controls.RadDatePicker' (Name='null'); target property is 'Value' (type 'DateTime>').

The type mentioned in the error messages is interesting, couldn't spot anything out of the ordinary in how the control behaves through dotPeek.

3) Binding to a Nullable<DateTime> property throws a runtime exception:

System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.UI.Xaml.Controls.DateTimePicker.get_Value()
   at Telerik.UI.Xaml.Controls.DateTimePicker.SyncPickerButtonContent()
   at Telerik.UI.Xaml.Controls.DateTimePicker.OnEmptyContentChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
   at Windows.UI.Xaml.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at Telerik.UI.Xaml.Controls.DateTimePicker.set_EmptyContent(Object value)
   at Telerik.UI.Xaml.Controls.RadDatePicker.OnTemplateApplied()
   at Telerik.UI.Xaml.Controls.RadControl.OnApplyTemplate()

Is this supported?

3 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 23 Jul 2012, 10:33 AM
Hi Brendan,

Thank you for your interest in RadControls for Metro and for your question.

Since the WinRT Binding Engine does not support Nullable<T> types, we have our own NullableValueType<T> implementation that is meant to serve as an equivalent to the system nullables. That's why if you need to use bindings you should use a special ValueConverter, available in the Telerik.Core assembly:

telerikCore:NullableValueTypeConverter

Still, it has minor bugs with the Convert and ConvertBack resolutions, which bugs we have already fixed in our development version. Please, find attached a demo app, together with the updated Converter, that you can use with our DateTime pickers.

We are currently preparing the documentation and we will have an article in it that describes why we need our own nullable types and how to use them.

I would like to thank you for your feedback and taking the time to contact us - it is much appreciated. Do not hesitate to write us back should you have any questions/problems with our tools.

Regards,
Georgi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Brendan
Top achievements
Rank 1
answered on 23 Jul 2012, 10:59 AM
Any clues as to when the next release will ship?
0
Tsvyatko
Telerik team
answered on 25 Jul 2012, 08:18 AM
Hi Brendan,

The release date is still TBD. However, when Microsoft release Win8 we will issue an compatible updated version of our controls, including this and other bugfixes as well.

All the best,
Tsvyatko
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
DatePicker for XAML
Asked by
Brendan
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Brendan
Top achievements
Rank 1
Tsvyatko
Telerik team
Share this question
or