This is a migrated thread and some comments may be shown as answers.

TKCalendar display only dates of current month for month view

3 Answers 246 Views
Calendar - Xamarin.iOS
This is a migrated thread and some comments may be shown as answers.
avinash
Top achievements
Rank 1
avinash asked on 26 Apr 2019, 12:24 PM

Hi Team,

I am using Calendar Control and in month view mode it currently shows 

previous month's last week dates and next months first week dates as well.

Is it possible to show only dates for current month .?

Please let me know how we could achieve it.

 

Thanks,

Avinash

 

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 01 May 2019, 10:46 AM
Hello Avinash,

You can hide the dates from the previous and last months through a CalendarDelegate and UpdateVisualsForCell method, however, keep in mind that this will not  affect the calculations that the calendar does to position its cells and it will still display 6 rows.

Here is a quick snippet:

public class CustomCalendarDelegate : CalendarDelegate
{
        public override void UpdateVisualsForCell(TKCalendar calendar, TKCalendarCell cell)
        {
            base.UpdateVisualsForCell(calendar, cell);
   
            var dayCell = cell as TKCalendarDayCell;
            if (dayCell != null)
            {
                dayCell.Hidden = (dayCell.State & TKCalendarDayState.CurrentMonth) == 0;
            }
        }
}


For additional information, please check Calendar Customizations topic.

Regards,
Yana
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
avinash
Top achievements
Rank 1
answered on 12 Jun 2019, 05:55 AM

Thanks Yana for reply,

It indeed helped me.

Is it possible to reduce the number of rows in order to show current months dates only?

 

 

0
Yana
Telerik team
answered on 12 Jun 2019, 11:32 AM
Hi Avinash,

I am afraid the count of the rows cannot be changed. You'd need to have 6 rows to ensure there will be enough room for all the dates of each month ( for example, if 1st is the last day of the week, 30th will be placed on the 6th row). 

An alternative approach would be to use the Flow ViewMode for RadCalendar on iOS, please check Calendar ViewModes topic for more details on this:
https://docs.telerik.com/devtools/xamarin/nativecontrols/ios/calendar/view-modes#flow-layout-with-months-and-month-days

Regards,
Yana
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Calendar - Xamarin.iOS
Asked by
avinash
Top achievements
Rank 1
Answers by
Yana
Telerik team
avinash
Top achievements
Rank 1
Share this question
or