Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to make entry like editor in Xamarin.Forms?

$
0
0

Hi,

I am creating a mobile application in that I need to send a message for query or support when the user creates that type of message and then click on return or done from keyboard entry height should be adjusted and if the user clicks on the back than it should also be managed. In that, I am not able to use Editor control. I am using a shared project to develop the application.

I try with the following code:

Sample.xaml

 <StackLayout Padding="50" HeightRequest="150">
    <Entry TextChanged="Entry_TextChanged" x:Name="EntryCustom"/>
 </StackLayout>

Sample.xaml.cs

private void Entry_TextChanged(object sender, TextChangedEventArgs args)
{
    int isElse = 0;
    if (args != null && args.OldTextValue != null && args.NewTextValue != null)
    {
        string[] oldval = args.OldTextValue.Split('\r');
        string[] Newval = args.NewTextValue.Split('\r');
        if (oldval.Count() > Newval.Count())
        {
            EntryCustom.HeightRequest = EntryCustom.HeightRequest - 33;
            isElse = 2;
        }
        else
            isElse = 1;
    }
    if (args.OldTextValue != null && (args.NewTextValue == "\n" || args.NewTextValue.EndsWith("\r")) && EntryCustom.HeightRequest < 100 && (isElse == 1 || args != null || args.OldTextValue.Count() > args.NewTextValue.Count()))
        EntryCustom.HeightRequest = EntryCustom.HeightRequest + 33;
}

Can anyone look into this and suggest me what should I have to change in the code?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>