I have a page and when it scrolling up I need a header part of my page should fade out and when scrolling out it should fade in. I tried to do this with fade in function actually I did it but its using time instead of the position.
The problem is Fade function support the time. I need to to fade away with position
I have tried
<ScrollView Scrolled="ScrollView_OnScrolled">
<StackLayout >
<AbsoluteLayout x:Name="AbsoluteLayout1" >
// header part
</AbsoluteLayout>
<StackLayout >
// body part
</StackLayout>
</StackLayout>
In my code behind i tried this
private double previousScrollPosition = 0;
private async void ScrollView_OnScrolled(object sender, ScrolledEventArgs e)
{
if (previousScrollPosition < e.ScrollY)
{
//scrolled up
previousScrollPosition = e.ScrollY;
await AbsoluteLayout1.FadeTo(0.2, 400, Easing.SinInOut);
}
}
else
{
//scrolled down
if (Convert.ToInt16(e.ScrollY) == 0)
previousScrollPosition = 0;
await AbsoluteLayout1.FadeTo(1, 400,Easing.SinIn);
}
}
How to set fadeaway with scrolling position on xamarin forms