Hello.
I would like to propose a new StartDay property.
Currently, we are using the FirstDayOfWeek property of CultureInfo.
In the case of Japan (ja-JP), CultureInfo's FirstDayOfWeek is set to start on Sunday,
but some people prefer a calendar that starts on Monday,
and I would like to switch between Sunday and Monday.
Therefore, I would like this property to be newly added.
Add the following code to CalendarPlugin/Shared/Controls/Calendar.xaml.
The description here is an error, so fix it.
DaysTitleMaximumLength="{Binding DaysTitleMaximumLength}, Source={x:Reference calendar}}"
↓
DaysTitleMaximumLength="{Binding DaysTitleMaximumLength, Source={x:Reference calendar}}"
Add the following code to CalendarPlugin/Shared/Controls/Calendar.xaml.cs.
public static readonly BindableProperty StartDayProperty =
BindableProperty.Create(nameof(StartDay), typeof(DayOfWeek), typeof(Calendar), DayOfWeek.Sunday,
propertyChanged: (bindable, oldValue, newValue) => {
(bindable as Calendar).ChangeStartDay((DayOfWeek)newValue, (DayOfWeek)oldValue);
},
defaultBindingMode: BindingMode.TwoWay);
protected void ChangeStartDay(DayOfWeek newValue, DayOfWeek oldValue)
{
if (newValue == oldValue) return;
StartDay = newValue;
}
public DayOfWeek StartDay {
get => (DayOfWeek)GetValue(StartDayProperty);
set => SetValue(StartDayProperty, value);
}
Added the following code to CalendarPlugin/Shared/Controls/MonthDaysView.xaml.cs.
/// <summary> Bindable property for StartDay </summary>
public static readonly BindableProperty StartDayProperty =
BindableProperty.Create(nameof(StartDay), typeof(DayOfWeek), typeof(MonthDaysView), DayOfWeek.Sunday,
propertyChanged: (bindable, oldValue, newValue) => {
(bindable as MonthDaysView).ChangeStartDay((DayOfWeek)newValue, (DayOfWeek)oldValue);
},
defaultBindingMode: BindingMode.TwoWay);
protected void ChangeStartDay(DayOfWeek newValue, DayOfWeek oldValue)
{
if (newValue == oldValue) return;
StartDay = newValue;
}
public DayOfWeek StartDay {
get => (DayOfWeek)GetValue(StartDayProperty);
set => SetValue(StartDayProperty, value);
}
Hello. I would like to propose a new StartDay property. Currently, we are using the FirstDayOfWeek property of CultureInfo. In the case of Japan (ja-JP), CultureInfo's FirstDayOfWeek is set to start on Sunday, but some people prefer a calendar that starts on Monday, and I would like to switch between Sunday and Monday. Therefore, I would like this property to be newly added.
Add the following code to CalendarPlugin/Shared/Controls/Calendar.xaml.
The description here is an error, so fix it. DaysTitleMaximumLength="{Binding DaysTitleMaximumLength}, Source={x:Reference calendar}}" ↓ DaysTitleMaximumLength="{Binding DaysTitleMaximumLength, Source={x:Reference calendar}}"
Add the following code to CalendarPlugin/Shared/Controls/Calendar.xaml.cs.
Added the following code to CalendarPlugin/Shared/Controls/MonthDaysView.xaml.cs.
-----------------------------------------------------
protected override void OnPropertyChanged([CallerMemberName] string propertyName = null) : : : case nameof(StartDay): <- add case nameof(Culture): UpdateDayTitles(); UpdateDays(AnimateCalendar); break;
-----------------------------------------------------
// var dayNumber = (int)Culture.DateTimeFormat.FirstDayOfWeek; <- delete var dayNumber = (int)StartDay; <- add
-----------------------------------------------------
// var addDays = ((int)Culture.DateTimeFormat.FirstDayOfWeek) - (int)monthStart.DayOfWeek; <- delete var addDays = ((int)StartDay) - (int)monthStart.DayOfWeek; <- add
----------------------------------------------------- Thank you for your cooperation.