如何使用“模式”显示文本;尾截断“;Xamarin表单上的编辑器?

如何使用“模式”显示文本;尾截断“;Xamarin表单上的编辑器?,xamarin,xamarin.forms,xamarin.android,xamarin.ios,Xamarin,Xamarin.forms,Xamarin.android,Xamarin.ios,我正在设计iPhone的布局 在文本框中,我用来输入文本 在iPhone的应用程序上,Editor可以以TailTruncation ======================== 我搜索并发现编辑器的属性与标签的属性相似 如何在Xamarin表单上使用Editor的TailTruncation模式显示文本 请帮帮我 您可以在上使用来实现尾截断。 大概是这样的: public class FullToShortConverter : IValueConverter {

我正在设计iPhone的布局

在文本框中,我用来输入文本

iPhone
的应用程序上,
Editor
可以以
TailTruncation

========================

我搜索并发现
编辑器
的属性与
标签
的属性相似

如何在
Xamarin表单上使用
Editor
TailTruncation
模式显示文本

请帮帮我

您可以在上使用来实现
尾截断
。 大概是这样的:

public class FullToShortConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string fullText = (string)value;
            string tempString = "";

            if (string.IsNullOrWhiteSpace(fullName)) {
                return string.Empty;
            }

            if (parameter == null) { // You can pass desired string length as a parameter
                // Assuming you want a string of length 10. 
                // Then 0..6 is 7 chars + three dots
                // There is no sense in changing the last 3 letters with ellipsis
                tempStr = fullText.Length > 10 ? fullText.Substring(0, 6) + "..." : fullText;
            } else {
                int maxChars = (int)parameter;
                tempStr = fullText.Length > maxChars ? fullText.Substring(0, maxChars - 3) + "..." : fullText;
            }

            return tempStr;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new InvalidCastException("Should never come here");
        }
    }

如果希望在用户与编辑器交互时显示/隐藏全文,则需要在
聚焦的
未聚焦的
事件中处理此问题。

如何处理
参数
?如果我们在
Focused
Unfocused
事件中处理它,怎么办?我找到了一个解决方案:code:
Binding Binding=new Binding(“Text”,BindingMode.OneWay,fullToShort,255,null,chatTextInput)
chatterxtinput.SetBinding(Editor.TextProperty,binding)