Can we add a nullable date picker? #1800
Closed
davidbuckleyni
started this conversation in
New Feature Discussions
Replies: 3 comments
-
This is far from anything production worthy but could you achieve this by wrapping something like: public class NullableDatePicker : ContentView
{
readonly Label label;
DateTime? date;
public DateTime? Date
{
get => date;
set
{
date = value;
label.Text = value?.ToShortDateString();
}
}
public NullableDatePicker()
{
DatePicker picker = new();
picker.TextColor = Colors.Transparent;
label = new Label
{
InputTransparent = true
};
picker.DateSelected += (sender, e) =>
{
Date = e.NewDate;
};
Button clearButton = new Button
{
Text = "X"
};
clearButton.Clicked += (sender, e) =>
{
Date = null;
};
Content = new Grid
{
ColumnDefinitions =
{
new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }
},
Children =
{
picker,
label,
clearButton
}
};
Grid.SetColumnSpan(picker, 2);
Grid.SetColumn(label, 0);
Grid.SetColumn(clearButton, 1);
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Closed as answered if you follow the thread from @acaliaro it is with the main MAUI team having an open PR, if closed in error please let us know to re-open. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The default date picker in Maui is not nullable; that is, it must have some value for form validation. Would it be possible to consider creating a toolkit control based on the existing date picker, but with the option to be nullable?
Currently, there are workarounds, but we strongly feel that having a control that is nullable upon form submission is essential.
We did have a discussion at time of maui release but the default control was so intermingled with date vars everywhere else made it hard to implement.
Beta Was this translation helpful? Give feedback.
All reactions