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

How do I work scrolling an entire page with Telerik's RadCalendar?

4 Answers 176 Views
Calendar & Scheduling
This is a migrated thread and some comments may be shown as answers.
Deepika
Top achievements
Rank 1
Deepika asked on 16 Jul 2019, 11:13 PM

When I place the RadCalendar within a scrollview like so:

<ScrollView>
<StackLayout>
<telerikInput:RadCalendar x:Name="calendar" ViewMode="Month" SelectionMode="Single" GridLinesDisplayMode="Hide"/>
<ListView/>
</StackLayout>
</ScrollView>

I can no longer scroll up to previous months using the Calendar itself. I do require both the calendar and the listview to be scrollable. Is it possible to change the way the month changes? Is it possible to use swiping left/right to move to the previous/next month?

If not, how can I work with this requirement?

4 Answers, 1 is accepted

Sort by
0
Didi
Telerik team
answered on 17 Jul 2019, 09:26 AM
Hi Deepika,

Thank you for the provided code.

A scenario where the RadCalendar is used within a ScrollView is not that common and such gesture conflicts might be observed as we have different native implementations of the RadCalendar for the different platforms. We have an issue logged in our feedback portal regarding this. You can follow the item on the link below:

https://feedback.telerik.com/xamarin/1416300-calendar-android-when-hosted-inside-scrollview-swipe-gestures-does-not-work

Solution:


Actually, the calendar in Android supports horizontal scrolling. You can achieve this through a custom renderer. Mainly you need to apply the following changes to the native element used for the RadCalendar in Android:
[assembly: ExportRenderer(typeof(RadCalendar), typeof(CustomCalendarRenderer))]
 
namespace AccColorConverter.Droid
{
    public class CustomCalendarRenderer : CalendarRenderer
    {
        public CustomCalendarRenderer(Context context) : base(context)
        {
 
        }
        protected override void OnElementChanged(ElementChangedEventArgs<RadCalendar> e)
        {
            base.OnElementChanged(e);
            this.Control.HorizontalScroll = true;
        }
    }
}

I have attached my test project for reference. Please review the CustomCalendarRenderer.cs file inside the Android project.

I hope the information provided will be useful. If you have any additional questions, do not hesitate to contact us.

Regards,
Didi
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
Deepika
Top achievements
Rank 1
answered on 17 Jul 2019, 05:41 PM

Hi Didi,

Thank you for your response. Since I'm building a cross platform app, I can't do anything for Android that I can't do for iOS. Is there a renderer that I can write for iOS too?

Instead, will I be able to move to another month using buttons? As in, by changing the selected date perhaps?

0
Deepika
Top achievements
Rank 1
answered on 17 Jul 2019, 05:42 PM
Sorry, I wanted to add: Can I disable the scroll altogether for the calendar? It does sometimes try to scroll and get stuck. If I can disable the scroll and navigate the months using buttons, that would work too
0
Didi
Telerik team
answered on 18 Jul 2019, 11:27 AM
Hi Deepika,

Let me get straight to your questiuons:

1) RadCalendar swipe left/right in order to navigate previous/next month:

By default the iOS calendar navigates to next/previous month while swiping right/left. On Android you should swipe up/down to navigate previous/next month. 
In order to achieve same behavior as on iOS, a custom render for Android should be implemented - as in the attached sample from my previous reply.

2) Avoid calendar stuck inside a ScrollView:

The swipe gesture could be disabled on iOS and Android through a custom renderer. For more details how to achieve this on iOS check the Calendar View Transitions help article from the native documentation, for Android refer to the Gestures and Transitions article

I have modified the previous attached project with section 2) implemented. Please note that you do not need a buttons for previous/next month navigation. For more details review the TouchListener class inside the CustomCalendarRenderer.cs file (Android project).

How to stop the transitions on iOS - review CustomCalendarRenderer.cs file inside the iOS project.

3) Further native calendar customization using a custom renderer:

Different solutions with the native Android and iOS calendar controls could be found in our Native Developer Focused Examples.They can be found in the /[installation-path]/Telerik UI for Xamarin [version]/Examples/ . Respectively, they are separated in different folders - iOS and Android.

I hope this will help.

Regards,
Didi
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 & Scheduling
Asked by
Deepika
Top achievements
Rank 1
Answers by
Didi
Telerik team
Deepika
Top achievements
Rank 1
Share this question
or