这是我的代码。我想将日历转换为波斯日历,我需要更改月份名称
PersianCalendar persianCalendar = new PersianCalendar();
DatePicker calObj = new DatePicker(FrContext);
DateTime minDate = new DateTime(1300, 1, 1, 0, 0, 0);
minDate = DateTime.SpecifyKind(minDate, DateTimeKind.Utc);
DateTimeOffset min_Date = minDate;
DateTime maxDate = new DateTime(1500, 1, 1, 0, 0, 0);
maxDate = DateTime.SpecifyKind(maxDate, DateTimeKind.Utc);
DateTimeOffset max_Date = maxDate;
calObj.MinDate = min_Date.ToUnixTimeMilliseconds();
calObj.MaxDate = max_Date.ToUnixTimeMilliseconds();
calObj.DateTime = new DateTime(persianCalendar.GetYear(DateTime.Now),
persianCalendar.GetMonth(DateTime.Now),
persianCalendar.GetDayOfMonth(DateTime.Now),
0,0,0,
persianCalendar.GetEra(DateTime.Now));
AlertDialog.Builder aaa = new AlertDialog.Builder(FrContext);
aaa.SetView(calObj);
aaa.Show();
我在下面的代码中使用了set culture month name。但没有工作
public override void OnCreate(Bundle savedInstanceState)
{
var clture = CultureInfo.CreateSpecificCulture("fa-IR");
clture.DateTimeFormat = new DateTimeFormatInfo()
{
MonthNames = new string[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" },
MonthGenitiveNames = new string[] { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند", "" }
};
CultureInfo.DefaultThreadCurrentCulture = clture;
Thread.CurrentThread.CurrentCulture = clture;
Thread.CurrentThread.CurrentUICulture = clture;
base.OnCreate(savedInstanceState);
// Create your fragment here
}
答案 0 :(得分:0)
我想将日历转换为波斯语日历,我需要更改月份名称
来自Xamarin.Forums
的答案:Another calendar type for datepicker。
正如MohammadRezaMoradi所说,你可以下载PersianMaterialDateTimePicker 并使用vs.
转换为dll例如:将PersianMaterialDateTimePicker
dll添加到您的项目中。然后像这样使用波斯语Datepicker
:
Com.Mohamadamin.Persianmaterialdatetimepicker.Date.DatePickerDialog d = new Com.Mohamadamin.Persianmaterialdatetimepicker.Date.DatePickerDialog();
d.Show(FragmentManager, "test");