MaterialDesignInXamlToolkit
MaterialDesignInXamlToolkit copied to clipboard
Jalali Material Date Picker C# WPF
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?
when I Select a date in Date Piker it Also Translate to Gregorian Calendar. and its Look Like This:
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 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}" />
I replaced the code you gave as an example in the project, which was as follows:
Any idea what I should do?
@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
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.
This issue was closed because it has been stalled for 14 days with no activity.