We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Want to use a "long press" effect in SfRotator or on any item in the rotator

With this https://alexdunn.org/2017/12/27/xamarin-tip-xamarin-forms-long-press-effect/ you can define a "LongPressEffect" to bind to any Element in forms to intercept a "long press". This works fine on Xamarin standard controls but not on a SfRotator. I tried to use it on a label inside a rotator item, this also does not work.

This works if not used in a SfRotator item:
<Label effects:LongPressedEffect.Command="{Binding BindingContext.LongPressCommand}">
<Label.Effects>
<effects:LongPressedEffect />
</Label.Effects>
This is the label to press long!
</Label>

Even this does not work:
<syncfusion_rotator:SfRotator
x:Name="SfRotator"
effects:LongPressedEffect.Command="{Binding LongPressCommand}"
DotsBorderColor="Transparent"
HeightRequest="150"
NavigationStripMode="Dots"
NavigationStripPosition="Bottom"
SelectedDotColor="{StaticResource Blue}"
UnselectedDotColor="{StaticResource CustomLightGray}">

<syncfusion_rotator:SfRotator.Effects>
<effects:LongPressedEffect />
</syncfusion_rotator:SfRotator.Effects>

I added a OnPropertyChanged handler to the sample to see the binding set of the command. In the cases it does not work this does not get called.


3 Replies

DR Dhanasekar R Syncfusion Team February 18, 2019 07:42 AM

Hi Bernd, 
 
Greetings from Syncfusion. 
 
We have checked your requirement on SfRotator for using Effect, we can provide ItemTemplate for the SfRotator, where we can use the effect which we need. 
 
<syncfusion:SfRotator x:Name="rotator">
  <syncfusion:SfRotator.ItemTemplate>
    <DataTemplate>
       <Label Text="Long Press Me!" local:LongPressedEffect.Command="{Binding NewCommand}">
            <Label.Effects>
                <local:LongPressedEffect />
            </Label.Effects>
        </Label>
    </DataTemplate>
  </syncfusion:SfRotator.ItemTemplate>
</syncfusion:SfRotator> 


 
Please check with the above case and let us know if you have clarification on this. 
 
If your requirement is differ from the above solution, please update us with more details link issue replication sample. This will be helpful for us to provide better solution on this. 
 
Regards, 
Dhanasekar 



UN Unknown February 18, 2019 08:46 AM

Thank you very much - it works.

Reason was the binding inside a ControlTemplate so the binding was not failed, but not found during runtime.


DR Dhanasekar R Syncfusion Team February 19, 2019 10:50 PM

Hi Bernd, 
 
Glad that the solution works. Please get back to us if any further assistance on this. 
 
Regards, 
Dhanasekar 


Loader.
Live Chat Icon For mobile
Up arrow icon