Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How to show multiple lines in an Editor????

GhaniGhani USMember ✭✭

I am using Editor in Xaml , in UI i am able to see an Editor but when i am going to use it like after entering some words and pressing enter the line moves up and is not visible .

Can anyone please help me out of the issue..

Thanks in Advance

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    Does your Editor occupy all free space? Have you set something like VerticalOptions = FillAndExpand

    https://developer.xamarin.com/api/property/Xamarin.Forms.View.VerticalOptions/

  • GhaniGhani USMember ✭✭
    edited October 2017

    i haven't set VerticalOptions = FillAndExpand.
    below is like what i have

    <Editor HeightRequest="50"/>
    
  • GhaniGhani USMember ✭✭
    edited October 2017
    <Editor HeightRequest="50"/>   
    

    This i What i have as if now.

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    @Ghani said:
    i haven't set VerticalOptions = FillAndExpand.
    below is like what i have

    Try to set

    VerticalOptions = LayoutOptions.FillAndExpand
    

    I think you have only one row because your height is too small

  • GhaniGhani USMember ✭✭

    i want it to be worked in xamarin forms .
    i think layoutOptions Wont work in xamarin forms

  • JulianPasqueJulianPasque USMember ✭✭✭
    edited October 2017

    This is what I do to get this working:

        public class EditorGrows : Editor
        {
            public EditorGrows()
            {
                this.TextChanged += (sender, e) =>
                {
    
                    if(Device.OS == TargetPlatform.Android)
                        this.InvalidateMeasure();
                };
            }
        }
    

    Put this inside a Grid, with automatic Rowheight set and it will expand as you expect.

    Best regards
    Julian

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    @Ghani said:
    i want it to be worked in xamarin forms .
    i think layoutOptions Wont work in xamarin forms

    LayoutOptions is for Xamarin Forms

  • IvanFranchiIvanFranchi USMember ✭✭

    @Ghani said:
    i want it to be worked in xamarin forms .
    i think layoutOptions Wont work in xamarin forms

    If not solved yet.. VerticalOptions="FillAndExpand" works in xaml files.
    My problem with Editor Control was showing multi line text. It wasn't automatically wrapping by itself.
    My solution is setting the orientation of the parent StackLayout.
    With Orientation="Vertical" the editor automatically shows the text properly. With horizontal it exceed the page margin.

  • aquabayaquabay AUMember ✭✭

    @IvanFranchi StackLayout orientation is vertical by default. A solution would have to also work with a horizontally orientated layout. Difficult to provide a solution if the code/xaml is not posted with question.

  • NjalEideNjalEide NOMember ✭✭

    Late answer, but might save some people some time. Just set AutoSize="TextChanges" on the Editor

Sign In or Register to comment.