Several problems with Customizing SfDataForm

I've recently added SfDataForm to my view which allows users to edit Person model. The DataForm itself works fine, but our app required some layout/display customization. To be exact, we had to change how label and text fields are rendered.


Following the documentation we extended the DataFormLayoutManager and overrided the GenerateViewForLabel and on EditorCreated methods, and then changed the DataForm object layoutManager to our class.

Problem is, those two methods are never entered, and the controls still have the default look.


The second problem lies within DatePicker controls for DateTime properties. Whenever user clicks on the field, an exception is thrown with description:

'Unable to add window -- token null is not valid; is your activity running?'


We've been stuck on those two for a while.


edit: Might be worth noting we're using Mvvmcross




1 Reply

MS Muniappan Subramanian Syncfusion Team June 24, 2021 12:30 PM UTC

Hi Dawid,  
 
Thank you for contacting Syncfusion support.  
 
Query: DataFormLayoutManager and overrided the GenerateViewForLabel and on EditorCreated methods does not called and when clicking the date editor exception thrown 
 
We have checked the reported issue’s and it’s working fine from our end. As per the instruction we have followed to check the reported issue and we are unable to replicate the issue from our end. To customize the layout, override the DataFormLayoutManager and assign to the SfDataForm.LayoutManager property in SfDataForm. We have attached the tested sample in the following link,  
 
Code snippet: 
dataForm.LayoutManager = new DataFormLayoutManagerExt(dataForm); 
public class DataFormLayoutManagerExt : DataFormLayoutManager 
{ 
    public DataFormLayoutManagerExt(SfDataForm dataForm) : base(dataForm) 
    { 
 
    } 
 
    protected override View GenerateViewForLabel(DataFormItem dataFormItem) 
    { 
        var view = base.GenerateViewForLabel(dataFormItem); 
        view.BackgroundColor = Color.Orange; 
        return view; 
    } 
 
    protected override void OnEditorCreated(DataFormItem dataFormItem, View editor) 
    { 
        base.OnEditorCreated(dataFormItem, editor); 
        editor.BackgroundColor = Color.Blue; 
    } 
} 
 
 
Additional information:  
Tested device: Moto G5 and iPhone simulator 
SfDataForm version: 19.1.0.69 
Xamarin Forms: 4.5.0.617 
 
Please check our sample and let us know if you still facing the same issue? if not, please modify our sample and revert us back with the following details which would be helpful for us to check on it and provide you the solution as soon as possible, 
 
·         Share the issue replicate video.  
·         Share the issue reproducible sample  
·         Share Dataform code snippets  
·         Share Syncfusion and Xamarin.Form’s version 
 
Regards,  
Muniappan S 


Loader.
Up arrow icon