I have a .Net MAUI app that displays a DatePicker:
<DatePicker
x:Name="AppointmentDatePicker"
Date="{Binding AppointmentDate}"
Margin="10" >
<DatePicker.Behaviors>
<toolkit:EventToCommandBehavior
Command="{Binding AppointmentDateChangedCommand}"
CommandParameter="{Binding Date, Source={x:Reference AppointmentDatePicker}}"
EventName="DateSelected" />
</DatePicker.Behaviors>
</DatePicker>
I need to show no date selected by default. If I set AppointmentDate property to null, the current date is displayed. This is confusing, as no date is in fact selected, so the user has wrong impression. How can I show no date selected by default?
I need to show no date selected by default.
You can use the Using Custom Renderers and custom control in .NET MAUI to create a CustomDatePicker
that supports nullable date.
Here's a working sample provided by divyesh. I've confirmed that it works fine in Android(see below screenshot) however in iOS custom renderer this.Control gives null.
You can follow up the link below if needed:
https://github.com/dotnet/maui/issues/12509
Screenshot in Android: