This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 45874 - Effect not attaching to ScrollView
Summary: Effect not attaching to ScrollView
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 2.3.2
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL: https://github.com/kristofberge/Scrol...
Depends on:
Blocks:
 
Reported: 2016-10-25 12:00 UTC by Kristof Bergé
Modified: 2017-07-05 10:22 UTC (History)
7 users (show)

See Also:
Tags: ScrollView, Effects
Is this bug a regression?: Yes
Last known good build:


Attachments

Description Kristof Bergé 2016-10-25 12:00:10 UTC
I'm trying to create an Effect and attach it to a ScrollView, but the effect is never attached. The effect is correctly instantiated and resolved to the appropriate PlatformEffect, but it is never attached to the ScrollView (OnAttached is never called). When I try to attach the same Effect in the same way to a different view (in this case a Label), the Effect is attached correctly.

NOTE: In the example I attach the effects in xaml, but the effect is the same when I try it in code-behind.

Creating the RoutingEffect:

public class TestEffect : RoutingEffect
{
    public TestEffect() : base("ScrollViewTest.TestEffect")
    {
    }
}
Creating the PlatformEffect (similar on iOS and Android):

[assembly: ResolutionGroupName("ScrollViewTest")]
[assembly: ExportEffect(typeof(TestEffectiOS), "TestEffect")]
namespace ScrollViewTest.iOS
{
public class TestEffectiOS : PlatformEffect
{

    protected override void OnAttached()
    {
        Debug.WriteLine($"Effect attached to {Element.GetType().ToString()}");
    }

    protected override void OnDetached()
    {
        Debug.WriteLine($"Effect detached from {Element.GetType().ToString()}");
    }
}
}

Attaching the effects in xaml:

<ScrollView>
    <Label
        Text="Welcome to Xamarin Forms!"
        VerticalOptions="Center"
        HorizontalOptions="Center">
        <Label.Effects>
            <local:TestEffect />
        </Label.Effects>
    </Label>
    <ScrollView.Effects>
        <local:TestEffect />
    </ScrollView.Effects>
</ScrollView>

Here's a test app that reproduces this on iOS and Android: https://github.com/kristofberge/ScrollViewTest
Comment 1 adrianknight89 2016-12-13 03:53:56 UTC
See https://github.com/xamarin/Xamarin.Forms/pull/641
Comment 2 Rui Marinho 2017-01-09 10:58:52 UTC
Should be fixed in 2.3.4-pre2
Comment 3 Parmendra Kumar 2017-02-06 16:33:08 UTC
I have checked this issue with Xamarin.Forms 2.3.4.192-pre2 and observed that this issue has been resolved with iOS and I am still getting issue with Android.

Screencast: https://www.screencast.com/t/ocyUWQtH

Application output:
Android: https://gist.github.com/Parmendrak/cf7d0094957420bf58d6b0e04c128181
iOS: https://gist.github.com/Parmendrak/ad403243bf2cf35be6c97440aad9eef4

Hence reopened this issue with respect to Android.

Thanks.
Comment 4 Samantha Houts 2017-03-22 21:02:48 UTC
https://github.com/xamarin/Xamarin.Forms/pull/836
Comment 5 Samantha Houts 2017-03-29 18:39:41 UTC
Should be fixed in 2.3.5-pre1. Thank you!
Comment 6 Saurabh Paunikar 2017-07-05 10:22:12 UTC
Verified on xamarin.form version 2.3.5.256-pre6

ScreenCast link: https://www.screencast.com/t/svkVafCX3Tv

Note You need to log in before you can comment on or make changes to this bug.