Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Image in scrollview is not scrolling in WPF xamarin.forms

$
0
0

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?


Viewing all articles
Browse latest Browse all 204402

Trending Articles