diff --git a/src/UraniumUI.Material/Extensions/AutoFormViewMaterialConfigurationExtensions.cs b/src/UraniumUI.Material/Extensions/AutoFormViewMaterialConfigurationExtensions.cs index a427ce6d..3741ea1e 100644 --- a/src/UraniumUI.Material/Extensions/AutoFormViewMaterialConfigurationExtensions.cs +++ b/src/UraniumUI.Material/Extensions/AutoFormViewMaterialConfigurationExtensions.cs @@ -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; @@ -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; @@ -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; } @@ -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; } @@ -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; } @@ -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; } }