Forum Xamarin.Forms

Animate ContentView - slide in/slide out

I have a ContentView and I have a button on my page. When i click the button i want the content view below to slide in top to bottom. Then i have another button and when that is clicked i want it to slide bottom to top away. Essentially i want to animate the process of changing visibility? How would I accomplish such a task?

     <ContentView x:Name="contentSlider" IsVisible="true"  BackgroundColor="#becedb" Margin="0" Grid.Row="2" VerticalOptions="Center">
                        <StackLayout Margin="10" Orientation="Horizontal" VerticalOptions="Center" HorizontalOptions="FillAndExpand">
                            <Slider MinimumTrackColor="White" Margin="0,0,5,0" HeightRequest="10"  MaximumTrackColor="White" x:Name="mileSlider" ValueChanged="SliderValueChanged"  Maximum="100" Minimum="10"  HorizontalOptions="FillAndExpand"></Slider>
                            <Label x:Name="lblMilesAway" Margin="0,5,0,0" TextColor="Black"  Text="{Binding Source={x:Reference mileSlider},Path=Value, StringFormat='up to {0:0} miles away'}"></Label>
                        </StackLayout>
                    </ContentView>

Answers

  • ColeXColeX Member, Xamarin Team Xamurai
    edited August 2018

    I think you can use scrollView to wrap your contentView , scroll contentView to the top or bottom when clicking the button.

    await scrollView.ScrollToAsync(contentView, ScrollToPosition.End,true);
    
Sign In or Register to comment.