Hi Rathana Kumar,
1.I am using Multi Selection mode.
2. Requirement :
I am developing a Travelling category mobile app using xamarin forms. In my scenario i want to select multiple dates in one tap. So i am using SF calendar with multi selection mode.
Here is my code
_calendarView = new SfCalendar();
_calendarView.SelectionMode = SelectionMode.MultiSelection;
_calendarView.NavigationButtonWidth = 10;
_calendarView.NavigationArrowThickness = 8;
_calendarView.ShowNavigationButtons = true;
_calendarView.ToggleDaySelection = true;
_calendarView.NavigateToMonthOnInActiveDatesSelection = true;
DateTime mindate = DateTime.Now.Date;
_calendarView.MinDate = mindate;
MonthLabelSettings labelSettings = new MonthLabelSettings();
labelSettings.DateFormat = "dd";
labelSettings.DayLabelSize = 20;
labelSettings.DayFormat = "EEE";
labelSettings.DateLabelSize = 12;
MonthViewSettings monthViewSettings = new MonthViewSettings();
monthViewSettings.TodayTextColor = App.AppColor;
monthViewSettings.InlineBackgroundColor = App.AppColor;
monthViewSettings.SelectedDayTextColor = Color.White;
monthViewSettings.DateSelectionColor = App.AppColor;
monthViewSettings.HeaderBackgroundColor = App.AppColor;
monthViewSettings.HeaderTextColor = Color.White;
monthViewSettings.DayHeaderTextColor = Color.White;
monthViewSettings.DayHeaderBackgroundColor = Color.FromHex("FF8B00");
monthViewSettings.MonthLabelSettings = labelSettings;
_calendarView.MonthViewSettings = monthViewSettings;
So i can able to select multiple dates. On Tap on Entry (or) Text box I am using popup to show the calendar so user select Start date and End Date popup will close and selected dates will appear in text box.
If user want to change the previous selected start date and End date. I am using below code for previous selecting dates by default.
List<DateTime> allDates = new List<DateTime>();
Here i am adding the dates which are previously selected.
if (previousStartdate != default(DateTime))
{
for (DateTime date = previousStartdate; date <= previousEnddate; date = date.AddDays(1))
allDates.Add(date);
}
In (all days) list i am getting complete list of selected dates.so i am assigning those dates to my calander control
foreach (var item in allDates)
{
_calendarView.SelectedDates.Add(item);
}
I can able to see the previous selected dates. If user select any new date i want to remove all previous selected dates.
I am using _calendarView.SelectionChanged += _calendarView_SelectionChanged; event to know the user selected the new date.
void _calendarView_SelectionChanged(object sender, SelectionChangedEventArgs args)
{
_calendarView.SelectedDates.Clear();
}
The clear event is not work forking for me.When i clear the _calendarView.SelectedDates. I able to see in backend the dates are clear but Calendar UI is not updated . Here i want to reset the previous selected dates and select the new date.
------------------------------------------------------------------------------------------------------------------
One more issue is In android _calendarView.SelectionChanged += _calendarView_SelectionChanged; automatically hitting the event without selecting the new date.And the method is hitting multiple times 6 to 7 times. In IOS it is working properly .I am using shared code so same logic will work for both but in android i am facing this _calendarView.SelectionChanged auto firing issue.
I am very new syncfusin control so please help me on this .
Thanks & Regards,
Mukesh.P