【问题标题】:How to make entry like editor in Xamarin.Forms?如何在 Xamarin.Forms 中像编辑器一样输入?
【发布时间】:2019-10-03 07:04:02
【问题描述】:

我正在创建一个移动应用程序,因为当用户创建该类型的消息然后单击返回或完成时,我需要发送一条消息以进行查询或支持,从键盘输入高度应该调整,如果用户单击比它还应该管理。在那,我无法使用Editor 控制。 我正在使用共享项目来开发应用程序。

我尝试使用以下代码:

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;
}

任何人都可以对此进行调查并建议我应该在代码中进行哪些更改?

【问题讨论】:

  • 我不太清楚你的问题,你为什么不能使用 AutoSize="TextChanges 的编辑器?你的要求是什么?
  • 在聊天应用程序中,如果我使用编辑器而不是在 iOS 中,它会在键盘右上角显示完成,这对于聊天应用程序来说很奇怪,所以我不想使用它。如果有任何东西由 rendere 管理,我也可以工作。
  • 您想更改键盘上的完成?可以加个截图吗?

标签: xamarin xamarin.forms xamarin.ios cross-platform xamarin-entry


【解决方案1】:

您应该使用编辑器。使用&lt;Editor AutoSize="TextChanges"/&gt;,编辑器会根据输入的文字调整大小。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-01
    • 2016-11-24
    • 2015-02-11
    • 1970-01-01
    • 2016-05-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多