Custom datePicker

Eduardo Gomez 3,651 Reputation points
2023-12-20T01:47:13.8433333+00:00

I notice that in the documentation (https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/datepicker?view=net-maui-8.0#Create%20a%20DatePicker)

I dent see any reference to Header or Title

How can I put a Title or Header to the datePicker?

What I want to do is this

 <Grid
     Margin="10"
     ColumnDefinitions="*,*"
     RowDefinitions="100,100,100,*">
     <inputLayout:SfTextInputLayout
         Grid.ColumnSpan="2"
         Hint="Coure name"
         IsHintAlwaysFloated="True"
         OutlineCornerRadius="8">
         <Entry />
     </inputLayout:SfTextInputLayout>

     <Button
         Grid.Row="1"
         Command="{Binding OpenPickerCommand}"
         HorizontalOptions="Start"
         Text="initial registration date"
         VerticalOptions="Start" />

     <Label
         Grid.Row="1"
         Grid.Column="1"
         Margin="0,10,0,0"
         Text="Initial date" />

     <Button
         Grid.Row="2"
         Command="{Binding OpenPickerCommand}"
         HorizontalOptions="Start"
         Text="End Registration date"
         VerticalOptions="Start" />

     <Label
         Grid.Row="2"
         Grid.Column="1"
         Margin="0,10,0,0"
         Text="End date" />

I have two buttons.

and two labels

both say Start registration date and end registration date.

I want to bind those selected dates to the labels (Those dates are registration date for courses)

public class Course {

    public int Id { get; set; }

    public string Name { get; set; }

    public string Description { get; set; }

    public string Teacher { get; set; }

    public DateOnly initialDate { get; set; } 

    public DateOnly endDate { get; set; }



I also wanted to know if is possible to select start date and end date with a Sigle DatePicker, to not clutter the ui

Developer technologies .NET .NET MAUI
{count} votes

1 answer

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,126 Reputation points Microsoft External Staff
    2023-12-22T06:21:51.63+00:00

    Hello,

    For how to migrate Renderer to MAUI Handler, the official documentation has been made, please refer to Migrate a Xamarin.Forms custom renderer to a .NET MAUI handler for more details.

    For the Windows platform, the corresponding native control is CalendarDatePicker. You could refer to the official API documentation to modify its properties.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.