chemli_ls
chemli_ls

Reputation: 21

Use of DatePicker

I'm trying .net maui platform, I created a form containing DatePicker. I would like everything to be in French (dd-mm-yyyy) unfortunately the result is always in English (mm-dd-yyyy). I've tried everything "format" in the XAML and format through c#, but nothing works.

Upvotes: 2

Views: 4100

Answers (2)

Alexandar May - MSFT
Alexandar May - MSFT

Reputation: 10078

The format property of the DatePicker only works on Android. On Windows platform, it is not working properly.

In addition, there is a known issue about this problem on Github. You can follow it up here:https://github.com/dotnet/maui/issues/7972.

Upvotes: 2

MNDevelopments
MNDevelopments

Reputation: 239

Since your aren't specifying if you are using the built in DatePicker or a thirdparty one I'm assuming you are using the built-in version. I'm also missing some information on what you've already tried, so I'm going to give you the simplest answer.

Firstly, take a look at the documentation for the DatePicker in .NET MAUI here

The DatePicker contains a format property that works like any C# date formatting. What you want is something like "dd/mm/yyyy" or similar.

The formatting can be done from both XAML and C# - In XAML it would look like this:

<DatePicker Format="dd/MM/yyyy"/>

And in C# something like this:

DatePicker datePicker = new DatePicker
{
    Format = "dd/MM/yyyy";
}

For a detailed documentation on the string formatting available in .NET you can look in the documentation here

Upvotes: 3

Related Questions