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

Is there a way to select only one date in a whole calendar control which has multiple months added in a year. #25

Closed
pradeeparutla opened this issue Jan 30, 2017 · 8 comments

Comments

@pradeeparutla
Copy link

Current functionality:

  1. If I have added 5 months in a calendar, I can select 5 different dates at one point of time(One date in each month). Date selection is provided month wise.

Do we have any option, so that if one date is selected in a calendar control(all other selected dates in other months also get deselected)

Requirement: Only one date should be selected in whole calendar control irrespective of date selected in different months.

@pradeeparutla
Copy link
Author

calendar_datesselected_differentmonths

I want only one date to be selected at a time. As in the image attached. total of two dates are selected in the calendar control.

@pradeeparutla pradeeparutla changed the title Atleast one date is selected in all the months Only one date should be selected in a whole calendar control which has multiple months added in a year. Jan 30, 2017
@pradeeparutla pradeeparutla changed the title Only one date should be selected in a whole calendar control which has multiple months added in a year. Is there a way to select only one date in a whole calendar control which has multiple months added in a year. Jan 30, 2017
@rebeccaXam
Copy link
Owner

Hallo, I do not understand how you added 5 months to the Calendar Control. To me it looks more like you added 5 Calendar controls after each other and you want one Date selected in all of these controls, am I correct?

When you used 5 Calendar Controls you could use:

public class CalendarVM : INotifyPropertyChanged
{
	public event PropertyChangedEventHandler PropertyChanged;
	private DateTime? _date;
	public DateTime? Date
	{
		get { return _date; }
		set
		{
			_date = value;
			PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Date));
		}
	}
}

And bind all the Calendar controls to the same BindingContext CalendarVM.

var vm = new CalendarVM();
calendar1.SetBinding(Calendar.SelectedDateProperty, nameof(vm.Date));
calendar1.BindingContext = vm;
calendar2.SetBinding(Calendar.SelectedDateProperty, nameof(vm.Date));
calendar2.BindingContext = vm;
etc...........

or in xaml

<controls:Calendar SelectedDate="{Binding Date}" />
<controls:Calendar SelectedDate="{Binding Date}" />
<controls:Calendar SelectedDate="{Binding Date}" />

Then the selected date in all controls will be the same.
Hoop this helps ;)

@pradeeparutla
Copy link
Author

Thankyou for the fast response.

To answer your question: I have added 5 different calendar controls one after each other to display more than one month at a time and Is there any other way I can add more than one month and scroll through the months using vertical scroll, same as the built in calendar control for iOS?

I hope I am missing something here.

If I am using the 5 different calendar controls for displaying 5 different months, then is there any way that, If I select a date in February then the date should be highlighted with some color, then the previously selected month in january to be unselected and color should be as normal date?

@pradeeparutla
Copy link
Author

pradeeparutla commented Jan 31, 2017

Hi RebeccaXam,

Thankyou for the fast response and a great control.

If I am using the 5 different calendar controls for displaying 5 different months, then my issue is now resolved using the solution provided by you.

So we can close this question. I have one related question with my implementation. If you are okay please answer it here, or else I will create it as a separate question.

Is there any other way by using only one calendar control, I can add more than one month and scroll through the months using vertical scroll, same as the built in calendar control for iOS devices?

@evandroabukamel
Copy link

I have interest in this too. I tried to attach gestures to the calendar but no success.

@rebeccaXam
Copy link
Owner

To show multiple months to scroll through use ShowNumOfMonths = (1-12) in version 1.0.8
I added this as a feature in 1.0.8, please reopen this issue, if it is not fully fulfilled or open a new issue.

@pradeeparutla
Copy link
Author

Thank you rebacca for the solution. When I am using 5 different calendar controls to display more than once calendar month, I have implemented your suggestion using the calendar view model to select only one date at a time in all the calendar controls. I am facing one new issue in android devices. Sometimes Date Clicked event is hitting twice on selecting a particular date other than the current month. Example: if current date selected in calendar is Jan 15th 2017, on selecting a date Feb 3rd 2017, Date clicked event is triggered twice(Event is triggering 2 times).

@VishVenu
Copy link

Hi,
I want to display one month dates at a time. Kindly help.

Eg: Currently it is showing Jan 1 to 31 and Feb 1 to to 11. I want to display only Jan 1 to 31 at a time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants