Image in scrollview is not scrolling in WPF xamarin.forms

saishaiksaishaik INMember ✭✭

I am trying for Zoom in-Zoom out for an image in WPF using xamarin.forms. The following is my code for zoom functionalities.

 <ContentPage.Content>
        <ScrollView>
            <StackLayout>
                <Image x:Name="ImageToDisplay"
               HorizontalOptions="Center"
                VerticalOptions="Center"
                Aspect="AspectFill" >
                </Image>
                <StackLayout Orientation="Horizontal" Grid.Row="1" HorizontalOptions="CenterAndExpand">
                    <Button Text="ZoomOut" Clicked="ZoomOut"/>
                    <Button Text="ZoomIn" Clicked="ZoomIn"/>
                </StackLayout>
            </StackLayout>
        </ScrollView>
    </ContentPage.Content>

private void ZoomIn(object sender, EventArgs e)
{
var currentScale = ImageToDisplay.Scale;

    if(currentScale>=1 && currentScale < 5)
    {
        ImageToDisplay.Scale = currentScale + 0.25;
    }
}

private void ZoomOut(object sender, EventArgs e)
{
    var currentScale = ImageToDisplay.Scale;

    if (currentScale >= 1 && currentScale < 5)
    {
        ImageToDisplay.Scale = currentScale - 0.25;
    }
}`

I can able to zoom in and zoom out but the problem is, when the image is zoomed to max it is not scrolling.

How to make it to be worked?

Sign In or Register to comment.