Johan Karlsson Johan Karlsson - 5 months ago 147
iOS Question

Scroll editor in Xamarin Forms into view

Using Xamarin Forms, consider the Xaml below.

<StackLayout VerticalOptions="FillAndExpand">
<Image x:Name="cameraImage" Source="camera.png" />
<Label Text="Describe the image" />
<Editor />
<Button Text="Save" />
</StackLayout>


This renders an image, an editor and a save button. The image is in 4x3 image ratio and covers about a third of the available screen height. The editor is rendered below.

The problem is that the keyboard covers the Editor in iOS. A standard iOS issue normally.

The question is: What is the Xamarin Forms way of handling this?

Thanks

// Johan

Answer

To get auto scroll for Editors and Entries with Xamarin.Forms, you usually just have to pack your View, in this case the StackLayout, into a ScrollView:

<ScrollView>
    <StackLayout VerticalOptions="FillAndExpand">
        <Image x:Name="cameraImage" Source="camera.png" />
        <Label Text="Describe the image" />
        <Editor />
        <Button Text="Save" />
    </StackLayout>
</ScrollView>

That's how it's supposed to work, but as of today (June 2014) there's a bug preventing this to work fully with the Editor (it works well with Entries). The issue is known and is worked on.

[UPDATE 2014-11-20]The issue has been addressed, and will be available in the next -pre release of XF 1.3

Comments