Category / Section
How to restrict swipe gesture in Calendar.?
1 min read
By default, SfCalendar allows to swipe the months or year. We can restrict the swiping gesture of SfCalendar by setting “false” value to EnableSwiping property. The default value of this property is True.
Create a SfCalendar View in XAML:
<?xml version="1.0" encoding="utf-8"?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:GettingStarted" xmlns:Syncfusion="clr-namespace:Syncfusion.SfCalendar.XForms;assembly=Syncfusion.SfCalendar.XForms" x:Class=" GettingStarted.GettingStartedPage"> <ContentPage.Content> <StackLayout x:Name="RestrictedLayout" > <Button x:Name="RestrictedButton" BackgroundColor="#ae330a" Clicked="Handle_Clicked" Text="Restriction on Swiping"/> <Syncfusion:SfCalendar x:Name="sfCalendar"/> </StackLayout> </ContentPage.Content> </ContentPage>
Code to restrict the Swiping gesture:
using Syncfusion.SfCalendar.XForms; using Xamarin.Forms; namespace GettingStarted { public partial class GettingStartedPage : ContentPage { void Handle_Clicked(object sender, System.EventArgs e) { //Restrict the swiping behaviour of calendar control has been achieved by using EnableSwiping sfCalendar.EnableSwiping = false; } public GettingStartedPage() { InitializeComponent(); } } }