I have an entity (just a POCO) called LookupValue. This class has two fields a Title and a Value. I use this entity for all types of drop down values (i.e. list of 50 U.S. states). I have a web service that returns a whole bunch of look up values that can be configured from a database. I'd like my Xamarin.Forms app to be able to consume these values by using a drop down field in the Data Form control to select one of them. However, I seem to be having trouble following the SourceProvider documentation found here: https://help.syncfusion.com/xamarin-android/sfdataform/editors
I've set my source provider and I've set the editor type manually but a drop down field still does not appear in the form.
Here's where I set the dataForm up in the view:
public PersonPrimaryResidenceEditorView ()
{
InitializeComponent ();
this.BindingContext = viewModel = new PersonPrimaryResidenceEditorViewModel();
dataForm.SourceProvider = new SourceProviderExt();
dataForm.RegisterEditor(typeof(LookupValue), "DropDown");
}
Here is my source provider implementation:
public class SourceProviderExt : SourceProvider
{
public override IList GetSource(string sourceName)
{
var list = new List<LookupValue>();
if (sourceName == "Province")
{
list.Add(new LookupValue("Ohio", "OH"));
list.Add(new LookupValue("California", "CA"));
}
return list;
}
}
Here is the property on the form:
private LookupValue province;
[Display(ShortName = "State")]
[Required(AllowEmptyStrings = false, ErrorMessage = "Please enter your state.")]
public LookupValue Province
{
get { return this.province; }
set
{
if (value != Province)
{
this.province = value;
this.RaisePropertyChanged("Province");
this.RaiseErrorChanged("Province");
}
}
}
I am starting to think that only Enums or List<string> is supported which would be very disappointing.