I'm working on a Xamarin.Forms project with MvvmCross. In one screen, I have a combo box to choose a field type: string
, number
, list
or date
. When a type is chosen, I have to show a custom input for the selected type: if it's string
, I have to show a normal Entry
, if it's Date
, a DatePicker
, etc.
How I can do that?
FieldType
.Bind it to all types of inputs like this:
IsVisible="{Binding FieldType, Converter={StaticResource IsEqualConverter}, ConverterParameter=current_field_type}"
Create IsEqualConverter
and inside compare FieldType
with parameter.
It will show and hide input fields based on selected FieldType
. You can read more about converters here: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/data-binding/converters