Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle nullable condition of types for AutoFormView #596

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static View EditorForString(PropertyInfo property, object source)
{
var editor = new TextField();
editor.SetBinding(TextField.TextProperty, new Binding(property.Name, source: source));
editor.AllowClear = true;
editor.AllowClear = property.PropertyType.IsNullable();
editor.Title = property.Name;

return editor;
Expand All @@ -43,7 +43,7 @@ public static View EditorForNumeric(PropertyInfo property, object source)
var editor = new TextField();
editor.SetBinding(TextField.TextProperty, new Binding(property.Name, source: source));
editor.Title = property.Name;
editor.AllowClear = false;
editor.AllowClear = property.PropertyType.IsNullable();
editor.Keyboard = Keyboard.Numeric;

return editor;
Expand Down Expand Up @@ -71,7 +71,7 @@ public static View EditorForEnum(PropertyInfo property, object source)
editor.ItemsSource = values;
editor.SetBinding(PickerField.SelectedItemProperty, new Binding(property.Name, source: source));
editor.Title = property.Name;
editor.AllowClear = false;
editor.AllowClear = property.PropertyType.IsNullable();
return editor;
}

Expand Down Expand Up @@ -111,7 +111,7 @@ public static View EditorForKeyboard(PropertyInfo property, object source)

editor.SetBinding(PickerField.SelectedItemProperty, new Binding(property.Name, source: source));
editor.Title = property.Name;
editor.AllowClear = false;
editor.AllowClear = property.PropertyType.IsNullable();
return editor;
}

Expand All @@ -120,7 +120,7 @@ public static View EditorForDateTime(PropertyInfo property, object source)
var editor = new DatePickerField();
editor.SetBinding(DatePickerField.DateProperty, new Binding(property.Name, source: source));
editor.Title = property.Name;
editor.AllowClear = false;
editor.AllowClear = property.PropertyType.IsNullable();
return editor;
}

Expand All @@ -129,7 +129,7 @@ public static View EditorForTimeSpan(PropertyInfo property, object source)
var editor = new TimePickerField();
editor.SetBinding(TimePickerField.TimeProperty, new Binding(property.Name, source: source));
editor.Title = property.Name;
editor.AllowClear = false;
editor.AllowClear = property.PropertyType.IsNullable();
return editor;
}
}