- Home
- Forum
- Xamarin.Forms
- Swipping on SfChart
Swipping on SfChart
I have been searching on SfChart documentation and I didn't find anything related to swipping gestures. But I see other controls has it. Is any example where there is a sfchart with swipping?
SIGN IN To post a reply.
3 Replies
YP
Yuvaraj Palanisamy
Syncfusion Team
September 7, 2021 09:41 AM UTC
Hi Lolo Rodri,
Greetings from Syncfusion.
We have analyzed your query and we have prepared the sample as per your requirement “Swipe gesture on SfChart” with the help of SwipeGestureRecognizer. Please find the code example below.
CodeSnippet: [MainPage.xaml]
|
<chart:SfChart x:Name="chart" InputTransparent="False"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<chart:SfChart.GestureRecognizers>
<SwipeGestureRecognizer Direction="Left" Swiped="SwipeGestureRecognizer_Swiped" Threshold="1"/>
<SwipeGestureRecognizer Direction="Right" Swiped="SwipeGestureRecognizer_Swiped" Threshold="1"/>
</chart:SfChart.GestureRecognizers>
. . .
</chart:SfChart> |
MainPage.xaml.cs
|
private void SwipeGestureRecognizer_Swiped(object sender, SwipedEventArgs e)
{
// Do Something
} |
Also, we have attached the sample for your reference. Please find the sample from the below link.
Note: When the chart interaction behaviors are enabled, the swipe gesture is not working. Hence, to remove the chart interaction behaviors such as Toolltip, Selection, Zooming.
Regards,
Yuvaraj.
LR
Lolo Rodri
September 7, 2021 12:09 PM UTC
Hi Yuvaraj,
Thank you for the example but I have one more doubt, is it possible to set a command in Swiped event? I didn't find Command like Button Click has.
YP
Yuvaraj Palanisamy
Syncfusion Team
September 7, 2021 02:54 PM UTC
Hi Lolo Rodri,
Yes, it is possible to set command in SwipeGesture. Please find the code example below.
MainPage.xaml
|
<chart:SfChart.GestureRecognizers>
<SwipeGestureRecognizer Direction="Left" Command="{Binding SwipeCommand}" Threshold="1"/>
<SwipeGestureRecognizer Direction="Right" Command="{Binding SwipeCommand}" Threshold="1"/>
</chart:SfChart.GestureRecognizers>
|
ViewModel.cs
|
public Command SwipeCommand { get; set; }
public ViewModel()
{
. . .
SwipeCommand = new Command(Swipe);
}
private void Swipe(object obj)
{
// Do Something
} |
Also, we have attached the modified sample for your reference. Please find the sample from the below link.
Please let us know if you have any concern.
Regards,
Yuvaraj.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
LR Lolo Rodri
- Sep 6, 2021 11:22 AM UTC
- Sep 7, 2021 02:54 PM UTC