Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jalali Material Date Picker C# WPF #3644

Open
abbaslele opened this issue Aug 7, 2024 · 4 comments
Open

Jalali Material Date Picker C# WPF #3644

abbaslele opened this issue Aug 7, 2024 · 4 comments
Labels
bug evaluation required Items is pending review or evaluation by the team Stale Issues and PRs that have not had activity for a while are marked with this label. Waiting on feedback Additional information is needed. Stale items with this label may be closed.

Comments

@abbaslele
Copy link

Bug explanation

I have a WPF application .net Framework platform and in the Xaml Side, I have changed the Culture as follows: When I use DatePicker, when I click on the date selection button, it shows me the Persian calendar correctly. However, when I select a date, it displays the Gregorian date in Persian numbers. When I click on the year at the top of the page to select the date, it shows me the Gregorian months in Persian. Then, when I click again, it shows me the Gregorian years. What should I do to solve this problem?

Screenshot 2024-08-07 084748

when I Select a date in Date Piker it Also Translate to Gregorian Calendar. and its Look Like This:
Screenshot 2024-08-07 085306

The Xaml code that I wrote for this date Picker is as follows:

<DatePicker
  Width="140" FlowDirection="RightToLeft"
  BorderThickness="2" Margin="8" Language="fa-IR" 
  materialDesign:HintAssist.Hint="تاریخ پایان"
  Style="{StaticResource MaterialDesignOutlinedDatePicker}" />

What I want is to be able to convert the months and years in Datepicker to the Jalali calendar, and after selecting, the Jalali date will be displayed in the text box.

Can this confusion in the Jalali and Gregorian calendars be resolved?

I would be grateful if you could help me in this regard.

What I want is to be able to convert the months and years in Datepicker to the Jalali calendar, and after selecting, the Jalali date will be displayed in the text box.

Version

5.1.0

@abbaslele abbaslele added bug evaluation required Items is pending review or evaluation by the team labels Aug 7, 2024
@nicolaihenriksen
Copy link
Contributor

@abbaslele I suspect this is not an issue with MDIX as such, but a general WPF issue that the DatePicker does not work well with some cultures...

Could you try with the XAML below to see if the same issue is present there? It effectively sets the style to null making it fallback to the default WPF style.

<DatePicker
  Width="140" FlowDirection="RightToLeft"
  BorderThickness="2" Margin="8" Language="fa-IR" 
  materialDesign:HintAssist.Hint="تاریخ پایان"
  Style="{x:Null}" />

@nicolaihenriksen nicolaihenriksen added the Waiting on feedback Additional information is needed. Stale items with this label may be closed. label Oct 9, 2024
@abbaslele
Copy link
Author

I replaced the code you gave as an example in the project, which was as follows:

image

Any idea what I should do?

@nicolaihenriksen
Copy link
Contributor

@abbaslele I am not familiar enough with Farsi to say if that is the expected result or not. My guess is that it is not, but I would need you to confirm that.

I believe this is a limitation in WPF; that it simply only has full support for Gregorian calendars. You can take a look at this article for somewhat of an explanation (although not WPF-specific), and possibly a way to get some of what you want. But whether you can get the DatePicker to behave nicely is not entirely clear to me.
https://learn.microsoft.com/en-us/dotnet/standard/base-types/how-to-display-dates-in-non-gregorian-calendars

Copy link
Contributor

This issue is marked stale because it has been open 30 days with no activity. Remove stale label or update the issue, otherwise it will be closed in 14 days.

@github-actions github-actions bot added the Stale Issues and PRs that have not had activity for a while are marked with this label. label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug evaluation required Items is pending review or evaluation by the team Stale Issues and PRs that have not had activity for a while are marked with this label. Waiting on feedback Additional information is needed. Stale items with this label may be closed.
Projects
None yet
Development

No branches or pull requests

2 participants