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
|
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;
}
} |