Good evening,
I am trying to get working date fields and the "third party source" (no decorations) way to generate a dataform but I just can't figure out how to solve this. I have read the documentation about the dataform and made some tests to adapt the code e.g. for the custom string DateTime converter.
I took the Telerik example in \Examples\XamarinForms\SDKBrowser\SDKBrowser\Examples\DataForm\DataFormCustomSource.xaml as a base and added a "Date" field inside the source dictionary.
I registered the date editor for the field after setting the source and also set some metadata for the field (a custom string DateTime converter, the DateRangeValidatorAttribute validator and the NativeConversionContext = DateTimeKind.Utc) but the code crashes before displaying the dataform. There is no other code changes.
How is it possible to achieve this?
When I load the data form, the debugger goes through the converter Convert method without problem before crashing. Here is the Exception I have:
Java.Lang.Error: DataFormDateEditor does not support properties of type String. Please specify a value converter for your property. ---> Java.Lang.ClassCastException: java.util.GregorianCalendar cannot be cast to java.lang.Number
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4009/3a62f1ea/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00084] in /Users/builder/data/lanes/4009/3a62f1ea/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11643
at Android.Runtime.JNIEnv.CallVoidMethod (System.IntPtr jobject, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x00000] in /Users/builder/data/lanes/4009/3a62f1ea/source/monodroid/src/Mono.Android/JNIEnv.g.cs:264
at Com.Telerik.Widget.Dataform.Visualization.RadDataForm.set_Entity (Com.Telerik.Widget.Dataform.Engine.IEntity value) [0x00067] in <ae3a3c051b4c45cab0d27f8036263c89>:0
at Telerik.XamarinForms.InputRenderer.Android.DataFormAdapter.UpdateEntity (Telerik.XamarinForms.Input.RadDataForm sourceOwner, Com.Telerik.Widget.Dataform.Visualization.RadDataForm targetOwner) [0x0003a] in <baeb1b2081654501888ace4ddb013183>:0
at Telerik.XamarinForms.InputRenderer.Android.DataFormAdapter.UpdateCore (Telerik.XamarinForms.Input.RadDataForm sourceOwner, Com.Telerik.Widget.Dataform.Visualization.RadDataForm targetOwner, System.String propertyName) [0x0001d] in <baeb1b2081654501888ace4ddb013183>:0
at Telerik.XamarinForms.Common.FacadeAdapterBase`2[S,T].Update (System.Object sourceOwner, System.Object targetOwner, System.String propertyName, System.Object sourceOwnerRoot, System.Object targetOwnerRoot) [0x00000] in <b09df7d4d5e74454b9482f9e64875b96>:0
at Telerik.XamarinForms.Common.XamarinToNativeControlExtensions.Update[T,K] (T nativeElement, K xfЕlement, System.String propertyName, System.Object sourceOwnerRoot, System.Object targetOwnerRoot) [0x0002b] in <b09df7d4d5e74454b9482f9e64875b96>:0
at Telerik.XamarinForms.InputRenderer.Android.DataFormRenderer.OnElementAttached (Telerik.XamarinForms.Input.RadDataForm newElement) [0x00032] in <baeb1b2081654501888ace4ddb013183>:0
at Telerik.XamarinForms.Common.Android.AndroidRendererBase`2[S,T].OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs`1[TElement] e) [0x00037] in <abbc9cd0d37b4c7ca6ff11fd056edf7f>:0
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000f4] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:196
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:137
at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x0001f] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Platform.cs:289
at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x00023] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:84
at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00104] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:217
at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:68
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:335
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x00111] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:199
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:137
at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Support.V4.App.FragmentManager fragmentManager) [0x00031] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Platform.cs:325
at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnCreateView (Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState) [0x00008] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:67
at Android.Support.V4.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_inflater, System.IntPtr native_container, System.IntPtr native_savedInstanceState) [0x00022] in <27c17fe440cf491ba8255bcefade6e02>:0
at (wrapper dynamic-method) System.Object:8b7a6b9b-c5f7-4699-a0b0-ed94f89278f8 (intptr,intptr,intptr,intptr,intptr)
--- End of managed Java.Lang.Error stack trace ---
OS: Win10 Pro 64bits 1511
Visual Studio 2015 Community: 14.25431.01 Update 3
Telerik: 2017.1.10321.10
Xamarin: 2.3.4.231
PCL: profile 111
Thanks!
Greg