毛伊岛:自定义条目

发布于 2025-02-01 18:50:54 字数 229 浏览 2 评论 0 原文

我是毛伊岛的新手,在Xamarin上具有基本知识。Forms

我想在毛伊岛的入口控制中添加一个底部边框(和边框滴答)。

在xamarin.forms上,我们必须为每个平台创建一个自定义控件,然后为每个平台创建一个渲染器。

在发布此消息之前,我在互联网上进行了研究。它涉及处理程序,我的印象是它仅允许基本修改(更改背景的颜色等等)。

我对所有这些信息有些困惑,如果有人能启发我,我会很感激。

I'm new to MAUI with basic knowledge on Xamarin.Forms

I would like to add a bottom border (and border tickness) to an Entry control in MAUI.

On Xamarin.Forms, we had to create a Custom Control and then a Renderer for each platforms.

I did research on the internet before posting this message. It concerns the Handlers and I have the impression that it only allows basic modifications (changing the color of the background, etc...).

I'm a bit confused with all this information, if anyone could enlighten me I would appreciate it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

傻比既视感 2025-02-08 18:50:54

显示了自定义条目的微不足道示例,该示例仅自定义每个平台的某些属性。

我已经开始创建一个。net Maui高级自定义输入示例。到目前为止,请参阅该存储库。

状态:

  • 演示窗户上的颜色和厚度下划线。
  • 已经开始在Android上的下划线。

限制(当前):

  • 在Windows上,一些条目 属性需要映射到包含的文本框。
  • 尚未测试条目 事件,查看它们是否需要任何特殊处理。
  • Android下划线无法控制其厚度或颜色。
  • 除Windows或iOS以外的平台上没有实现。

如果您想扩展此更远的,Google Xamarin表单自定义输入渲染器用于平台特定代码的示例。希望我已经表现出足够的表现,可以使如何/添加此类代码有所了解。


目前,做一个先进的示例似乎比相应的Xamarin表单“自定义渲染器”更多。

原因:

  • 需要适应毛伊岛的处理程序映射方案。可能只需要高级文档和示例。
  • 由于 iEntry ientryhandler 所需的类型,因此很难扩展现有的入门手机。如何替代 PlatformView 的类型?
  • 难以复制现有处理程序的作用(以进行稍作更改),因为内置处理程序使用的某些扩展是“内部”,因此必须复制这些文件。转介到其他文件。然后我复制了。并进行了一些更改,以避免与现有扩展的歧义冲突。

TBD:也许有一种方法可以避免我遇到的并发症。
另外,我可能会复制代码,可以省略。


这些是需要完成的步骤:

  1. 定义类 myentry:entry 具有所需的其他属性。
  2. 定义类 myentryhandler 渲染到本机UI对象。
  3. 在Mauiprogram中的Addhandler。

1。定义类 myentry:entry 带有所需的其他属性。

在这里,我们添加 UnderlineColor UnderlineThickness

public class MyEntry : Entry
{
    /// <summary>
    /// Color and Thickness of bottom border.
    /// </summary>
    public static BindableProperty UnderlineColorProperty = BindableProperty.Create(
            nameof(UnderlineColor), typeof(Color), typeof(MyEntry), Colors.Black);
    public Color UnderlineColor
    {
        get => (Color)GetValue(UnderlineColorProperty);
        set => SetValue(UnderlineColorProperty, value);
    }

    public static BindableProperty UnderlineThicknessProperty = BindableProperty.Create(
            nameof(UnderlineThickness), typeof(int), typeof(MyEntry), 0);
    public int UnderlineThickness
    {
        get => (int)GetValue(UnderlineThicknessProperty);
        set => SetValue(UnderlineThicknessProperty, value);
    }

    public MyEntry()
    {
    }
}

2。定义类 myentryhandler 渲染到本机UI对象。

这是通过 partial class 来完成的。一个部分是跨平台,然后需要您实现的每个平台的另一部分。

在我的存储库中,查找 myentryhandler.cs Windows/myentryhandler.windows.cs android/myentryhandler.android.cs

myentryhandler.cs:

这包含Myentryhandler的“映射”。

    // Cross-platform partial of class. See Maui repo maui\src\Core\src\Handlers\Entry\EntryHandler.cs
    public partial class MyEntryHandler : IMyEntryHandler //: EntryHandler
    {
        // static c'tor.
        static MyEntryHandler()
        {
            // TBD: Fill MyMapper here by copying from Entry.Mapper, then add custom ones defined in MyEntry?
        }

        //public static IPropertyMapper<IEntry, IEntryHandler> MyMapper => Mapper;
        public static IPropertyMapper<IEntry, MyEntryHandler> MyMapper = new PropertyMapper<IEntry, MyEntryHandler>(ViewMapper)
        {
            // From Entry.
            [nameof(IEntry.Background)] = MapBackground,
            [nameof(IEntry.CharacterSpacing)] = MapCharacterSpacing,
            [nameof(IEntry.ClearButtonVisibility)] = MapClearButtonVisibility,
            [nameof(IEntry.Font)] = MapFont,
            [nameof(IEntry.IsPassword)] = MapIsPassword,
            [nameof(IEntry.HorizontalTextAlignment)] = MapHorizontalTextAlignment,
            [nameof(IEntry.VerticalTextAlignment)] = MapVerticalTextAlignment,
            [nameof(IEntry.IsReadOnly)] = MapIsReadOnly,
            [nameof(IEntry.IsTextPredictionEnabled)] = MapIsTextPredictionEnabled,
            [nameof(IEntry.Keyboard)] = MapKeyboard,
            [nameof(IEntry.MaxLength)] = MapMaxLength,
            [nameof(IEntry.Placeholder)] = MapPlaceholder,
            [nameof(IEntry.PlaceholderColor)] = MapPlaceholderColor,
            [nameof(IEntry.ReturnType)] = MapReturnType,
            [nameof(IEntry.Text)] = MapText,
            [nameof(IEntry.TextColor)] = MapTextColor,
            [nameof(IEntry.CursorPosition)] = MapCursorPosition,
            [nameof(IEntry.SelectionLength)] = MapSelectionLength,
            // From MyEntry
            [nameof(MyEntry.UnderlineThickness)] = MapUnderlineThickness
        };

        // TBD: What is this for? Cloned one on Entry.
        private static void MapUnderlineThickness(MyEntryHandler arg1, IEntry arg2)
        {
        }


        public MyEntryHandler() : base(MyMapper)
        {
        }

我尚未在所有平台文件夹中创建最小的部分类别。在Repo的跨平台myentryhandler中,您会在 #if Windows 中看到代码。目的是,这不需要包裹在 #if 中。您还会看到很多评论的代码;这样我就可以看到每个平台上都需要实现哪些方法。

myentryhandler.windows.cs:

本质是 createplatformview()。在Windows上,我选择以 border (底部除外)为 textbox

        protected override PlatformView CreatePlatformView()
        {
            var myentry = VirtualView as MyEntry;

            var textbox = new MauiPasswordTextBox
            {
                // From EntryHandler.
                IsObfuscationDelayed = s_shouldBeDelayed

                // TODO: pass some entry properties through to textbox?
            };

            MauiColor color = myentry != null
                    ? myentry.UnderlineColor
                    : MyEntry.UnderlineColorProperty.DefaultValue as MauiColor;
            int thickness = myentry != null
                    ? myentry.UnderlineThickness
                    : (int)MyEntry.UnderlineThicknessProperty.DefaultValue;

            var border = new Border
            {
                Child = textbox,
                BorderBrush = color.ToPlatform(),
                BorderThickness = new Thickness(0, 0, 0, thickness)
            };


            return border;
        }

Windows处理程序还有许多其他行。这些都是从毛伊岛来源复制的。 TBD需要哪些(如果有)。如果我想出了如何简单地从毛伊岛的入口汉(Handhandler)继承,那将不需要这些。但是,当我继承时,有类型冲突。


3:Mauiprogram中的Addhandler。

mauiprogram.cs

    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<App>()
            .ConfigureMauiHandlers(handlers =>
            {
                handlers.AddHandler(typeof(MyEntry), typeof(MyEntryHandler));
            })
        ...

您会看到其他类别添加到Repo中的MAUI项目中。这些是从毛伊岛来源复制的。

这些其他类别由上述类引用。

希望一旦更好地理解此主题,其他大多数课程都会消失。


在Windows上,AppShell + Mainpage带有两个Myentrys。一个是下划线和彩色的。

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:myviews="clr-namespace:MauiCustomEntryHandler"
             x:Class="MauiCustomEntryHandler.MainPage">
             
    <ScrollView>
        <VerticalStackLayout 
                WidthRequest="500" HeightRequest="400"
                Spacing="25" Padding="30,0" BackgroundColor="LightBlue"
                HorizontalOptions="Center" VerticalOptions="Center">
            <Label Text="Hello, Maui!" FontSize="24" HorizontalOptions="Center" />
            <myviews:MyEntry Text="test" FontSize="20" UnderlineThickness="8"
                 UnderlineColor="Purple" BackgroundColor="HotPink" />
            <myviews:MyEntry UnderlineThickness="0" BackgroundColor="LightGray" />
        </VerticalStackLayout>
    </ScrollView>
 
</ContentPage>

Customize specific control instances shows a trivial example of a custom Entry, that only customizes some properties per platform.

I've started to create a .Net Maui advanced custom Entry example. See that repo for the implementation so far.

Status:

  • Demonstrates underline color and thickness on Windows.
  • Has beginnings of an underline on Android.

Limitations (current):

  • On Windows, some Entry properties need to be mapped to the contained TextBox.
  • Have not yet tested Entry events, to see if they need any special handling.
  • The Android underline has no control over its thickness or color.
  • No implementation on platforms other than Windows or iOS.

If you wish to extend this farther, google xamarin forms customize entry renderer for examples of platform-specific code. Hopefully I've shown enough to give a sense of how/where to add such code.


At this time, doing an advanced example seemed to be MORE work than the corresponding Xamarin Forms "custom renderers".

REASONS:

  • The need to fit into Maui's handler mapping scheme. Probably just need advanced documentation and examples.
  • Difficulty extending existing EntryHandler, due to types needed by IEntry and IEntryHandler. HOW OVERRIDE type of PlatformView??
  • Difficulty replicating what existing handler does (in order to make slight changes), because some Extensions used by built-in handlers are "internal", so had to copy those files. Which referred to other files. That I then copied. And made some changes to avoid ambiguity conflicts with the existing Extensions.

TBD: Perhaps there is a way to avoid the complications I encountered.
ALSO there may be code I copied, that could be omitted.


These are the steps that need to be done:

  1. Define class MyEntry : Entry with desired additional properties.
  2. Define class MyEntryHandler to render to native UI object(s).
  3. AddHandler in MauiProgram.

1. Define class MyEntry : Entry with desired additional properties.

Here, we add UnderlineColor and UnderlineThickness.

public class MyEntry : Entry
{
    /// <summary>
    /// Color and Thickness of bottom border.
    /// </summary>
    public static BindableProperty UnderlineColorProperty = BindableProperty.Create(
            nameof(UnderlineColor), typeof(Color), typeof(MyEntry), Colors.Black);
    public Color UnderlineColor
    {
        get => (Color)GetValue(UnderlineColorProperty);
        set => SetValue(UnderlineColorProperty, value);
    }

    public static BindableProperty UnderlineThicknessProperty = BindableProperty.Create(
            nameof(UnderlineThickness), typeof(int), typeof(MyEntry), 0);
    public int UnderlineThickness
    {
        get => (int)GetValue(UnderlineThicknessProperty);
        set => SetValue(UnderlineThicknessProperty, value);
    }

    public MyEntry()
    {
    }
}

2. Define class MyEntryHandler to render to native UI object(s).

This is done with a partial class. One part is cross-platform, then need another part for each platform that you implement.

In my repo, find MyEntryHandler.cs, Windows/MyEntryHandler.Windows.cs, and Android/MyEntryHandler.Android.cs.

MyEntryHandler.cs:

This contains the "Mapper" for MyEntryHandler.

    // Cross-platform partial of class. See Maui repo maui\src\Core\src\Handlers\Entry\EntryHandler.cs
    public partial class MyEntryHandler : IMyEntryHandler //: EntryHandler
    {
        // static c'tor.
        static MyEntryHandler()
        {
            // TBD: Fill MyMapper here by copying from Entry.Mapper, then add custom ones defined in MyEntry?
        }

        //public static IPropertyMapper<IEntry, IEntryHandler> MyMapper => Mapper;
        public static IPropertyMapper<IEntry, MyEntryHandler> MyMapper = new PropertyMapper<IEntry, MyEntryHandler>(ViewMapper)
        {
            // From Entry.
            [nameof(IEntry.Background)] = MapBackground,
            [nameof(IEntry.CharacterSpacing)] = MapCharacterSpacing,
            [nameof(IEntry.ClearButtonVisibility)] = MapClearButtonVisibility,
            [nameof(IEntry.Font)] = MapFont,
            [nameof(IEntry.IsPassword)] = MapIsPassword,
            [nameof(IEntry.HorizontalTextAlignment)] = MapHorizontalTextAlignment,
            [nameof(IEntry.VerticalTextAlignment)] = MapVerticalTextAlignment,
            [nameof(IEntry.IsReadOnly)] = MapIsReadOnly,
            [nameof(IEntry.IsTextPredictionEnabled)] = MapIsTextPredictionEnabled,
            [nameof(IEntry.Keyboard)] = MapKeyboard,
            [nameof(IEntry.MaxLength)] = MapMaxLength,
            [nameof(IEntry.Placeholder)] = MapPlaceholder,
            [nameof(IEntry.PlaceholderColor)] = MapPlaceholderColor,
            [nameof(IEntry.ReturnType)] = MapReturnType,
            [nameof(IEntry.Text)] = MapText,
            [nameof(IEntry.TextColor)] = MapTextColor,
            [nameof(IEntry.CursorPosition)] = MapCursorPosition,
            [nameof(IEntry.SelectionLength)] = MapSelectionLength,
            // From MyEntry
            [nameof(MyEntry.UnderlineThickness)] = MapUnderlineThickness
        };

        // TBD: What is this for? Cloned one on Entry.
        private static void MapUnderlineThickness(MyEntryHandler arg1, IEntry arg2)
        {
        }


        public MyEntryHandler() : base(MyMapper)
        {
        }

I did not yet create minimal partial classes in ALL platform folders. In the repo's cross-platform MyEntryHandler, you'll see code inside #if WINDOWS. The intent is that this NOT need to be wrapped in #if. You'll also see a lot of commented out code; this was so I could see what methods needed to be implemented on each platform.

MyEntryHandler.Windows.cs:

The essence is CreatePlatformView(). On Windows, I chose to implement as a Border (with zero on all sides except bottom) containing a TextBox.

        protected override PlatformView CreatePlatformView()
        {
            var myentry = VirtualView as MyEntry;

            var textbox = new MauiPasswordTextBox
            {
                // From EntryHandler.
                IsObfuscationDelayed = s_shouldBeDelayed

                // TODO: pass some entry properties through to textbox?
            };

            MauiColor color = myentry != null
                    ? myentry.UnderlineColor
                    : MyEntry.UnderlineColorProperty.DefaultValue as MauiColor;
            int thickness = myentry != null
                    ? myentry.UnderlineThickness
                    : (int)MyEntry.UnderlineThicknessProperty.DefaultValue;

            var border = new Border
            {
                Child = textbox,
                BorderBrush = color.ToPlatform(),
                BorderThickness = new Thickness(0, 0, 0, thickness)
            };


            return border;
        }

There are many other lines of the Windows Handler. These are all copied from Maui source. TBD which (if any) of these are needed. If I'd figured out how to simply inherit from Maui's EntryHandler, those would not be needed. But there were type conflicts when I inherited.


3: AddHandler in MauiProgram.

MauiProgram.cs

    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<App>()
            .ConfigureMauiHandlers(handlers =>
            {
                handlers.AddHandler(typeof(MyEntry), typeof(MyEntryHandler));
            })
        ...

You'll see other classes added to the Maui project in repo. These are copied from Maui sources.

These other classes are referenced by the classes mentioned above.

Hopefully most of the other classes go away, once this topic is better understood.


On Windows, AppShell + MainPage with two MyEntrys. One is underlined and colored.

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:myviews="clr-namespace:MauiCustomEntryHandler"
             x:Class="MauiCustomEntryHandler.MainPage">
             
    <ScrollView>
        <VerticalStackLayout 
                WidthRequest="500" HeightRequest="400"
                Spacing="25" Padding="30,0" BackgroundColor="LightBlue"
                HorizontalOptions="Center" VerticalOptions="Center">
            <Label Text="Hello, Maui!" FontSize="24" HorizontalOptions="Center" />
            <myviews:MyEntry Text="test" FontSize="20" UnderlineThickness="8"
                 UnderlineColor="Purple" BackgroundColor="HotPink" />
            <myviews:MyEntry UnderlineThickness="0" BackgroundColor="LightGray" />
        </VerticalStackLayout>
    </ScrollView>
 
</ContentPage>

enter image description here

叹沉浮 2025-02-08 18:50:54

如果有人因为(看似)简单需要更改下划线颜色而降落在此页面上,请继续阅读。下面的解决方案仅需几条线条,可用于所有使用突出显示 /重音颜色的毛伊岛控件。

接受的答复似乎是关于如何自定义毛伊岛控件的通用描述的宝贵教程(这再次与原始问题的标题相对应,可能是一般性的)。但是,如果颜色行为是您唯一的目标,那将是总杀伤力。

MAUI实施基于OS个性化计划。不幸的是,对于所有平台,似乎并不能以一般的方式在一个地方以一般的方式覆盖它,而可以在平台特定的层上控制它。

我最终得到的是仅修改一个文件

    <maui:MauiWinUIApplication.Resources>
        <ResourceDictionary>
            <Color x:Key="Primary">#500073</Color>
            <StaticResource x:Key="SystemAccentColorDark1" ResourceKey="Primary"/>
            <StaticResource x:Key="SystemAccentColorDark2" ResourceKey="Primary"/>
            <StaticResource x:Key="SystemAccentColorDark3" ResourceKey="Primary"/>
            <StaticResource x:Key="SystemAccentColorLight1" ResourceKey="Primary"/>
            <StaticResource x:Key="SystemAccentColorLight2" ResourceKey="Primary"/>
            <StaticResource x:Key="SystemAccentColorLight3" ResourceKey="Primary"/>
        </ResourceDictionary>
    </maui:MauiWinUIApplication.Resources>

。使用这种重音颜色。

尽管我的Windows设置设置为蓝色,如当前的重音颜色:

“

我最初尝试修改通用./ resources/styles/styles/colors.xaml文件,以期希望立即在所有平台上覆盖这种行为,但这似乎不起作用。希望毛伊岛团队有一天能够实施通用行为。

If anyone lands on this page because of a (seemingly) simple need to change the underline color only please continue reading. The solution below takes only few lines and works for ALL MAUI controls that use highlighting / accent colors.

The accepted reply seems to be a valuable tutorial for the generic description of how to customize MAUI controls (which again corresponds to the title of the original question written possibly bit much generically). If however the color behavior is your only goal it would be a total overkill.

The MAUI implementation is based on OS personalization scheme. Unfortunately it does not seem one can override it in a general way on one place for all platforms but it is possible to control it on the platform-specific layer.

What I ended up with is modification of one file only, namely ./Platforms/Windows/App.xaml:

    <maui:MauiWinUIApplication.Resources>
        <ResourceDictionary>
            <Color x:Key="Primary">#500073</Color>
            <StaticResource x:Key="SystemAccentColorDark1" ResourceKey="Primary"/>
            <StaticResource x:Key="SystemAccentColorDark2" ResourceKey="Primary"/>
            <StaticResource x:Key="SystemAccentColorDark3" ResourceKey="Primary"/>
            <StaticResource x:Key="SystemAccentColorLight1" ResourceKey="Primary"/>
            <StaticResource x:Key="SystemAccentColorLight2" ResourceKey="Primary"/>
            <StaticResource x:Key="SystemAccentColorLight3" ResourceKey="Primary"/>
        </ResourceDictionary>
    </maui:MauiWinUIApplication.Resources>

This way your color will override the OS system one and to my best guess this will modify behavior of all controls on the given platform that uses this accent color.

Entry with customized underline color

In spite of my Windows setting show blue as the current accent color:

Windows OS Setting Colors

Originally I tried to modify the generic ./Resources/Styles/Colors.xaml file in a hope to override this behavior on ALL PLATFORMS at once but that did not seem to work. Hopefully MAUI team implements the generic behavior one day.

柠栀 2025-02-08 18:50:54

我不喜欢解决简单问题的漫长解决方案。 MAUI支持(有限的)CSS,所以这是我所做的

  1. 创建stylesheet style.css (称其为您喜欢的内容),并将其放在“/资源”中位置很重要

    .bottom-border {

     边界底:1px实心黑色;
     

    }

  2. 在app.xaml中添加一个条目以访问样式表

    &lt; application.resources&gt;

     &lt; stylesheet source =“/resources/style.css”/&gt;
     

    &lt;/application.resources>

您不能将其与现有资源词典混合在一起,但是无论如何,我都不需要它们,只要您对CSS不太冒险,您就可以做大多数事情,所以这不是问题。我不是毛伊岛风格的忠实拥护者,这似乎很少有所收获,但这只是我。在这里检查使用级联样式表

  1. 添加此 ... styleclass =“ Bottom-Border” 到您的元素,然后!

I'm not a fan of long-winded solutions for simple problems. Maui supports (limited) CSS, so here's what I did

  1. create a stylesheet style.css (call it what you like) and put it in the '/Resources' I don't think the location matters that much

    .bottom-border {

     border-bottom:1px solid black;
    

    }

  2. Add an entry in App.xaml to access the stylesheet

    <Application.Resources>

     <StyleSheet Source="/Resources/style.css" />
    

    </Application.Resources>

You can't mix this with existing resource dictionaries, but I didn't need them anyway, and as long as you don't get too adventurous with your CSS you can do most things, so it's not a problem. I'm not a big fan of MAUI styling, it just seems like a lot of effort for little gain, but that's just me. Check here Style apps using Cascading Style Sheets

  1. Add this ... StyleClass="bottom-border" to your element, and boom!

enter image description here

酷遇一生 2025-02-08 18:50:54

尽管这个问题有些古老,但我认为对于某些.NET MAUI开发人员来说,知道 Android 的颜色强调定义可能很有用。在此特定资源目录中定义了Android颜色的重音:

”

这些颜色定义负责入口边框 color ,可能是其他一些颜色重音,特别是针对Android设备。不幸的是,这不会改变边界厚度,半径或任何其他形状样式。通常,改变颜色对我来说足够了。在我看来,厚边界使该条目更容易进入。

请注意:与您整个项目的颜色定义相反,Android的定义是用 soulder Case 编写的,而未大写。您还必须使用 name 而不是 x:key 属性,或者可能会引发有关不工作的值转换器的例外。

因此...

而不是 &lt; color x:key =“ primary”&gt;#00ffff&lt;/color&gt;

您将定义颜色,例如 &lt;颜色名称=“ colorprimary”&gt;#00ffff&lt;/color&gt;

Although this question is a bit old, I figured it might be useful for some .NET MAUI developers to know there are color accent definitions for Android specifically. Android color accents are defined within this specific resource directory:

Android platform resource directory

These color definitions are responsible for the entry border color and probably a few other color accents, specifically for Android devices. Unfortunately this does not change the border thickness, radius or any other shape styling. Usually changing the color is enough for me though. The thick border makes the entry more accessible in my opinion.

Please note: Contrary to the color definitions for your entire project, the definitions for Android are written in lower case and not capitalized. You also have to use name instead of x:Key attributes or it might throw an exception about value converters not working.

So...

instead of <Color x:Key="Primary">#00FFFF</Color>
you'll define colors like <color name="colorPrimary">#00FFFF</color>

澉约 2025-02-08 18:50:54

公认的答案真的很复杂。如何使用网格 frame 条目 boxview yeke:

<Grid>
    <Frame Padding="0" />
    <Entry
        Margin="5,0,5,0"
        Placeholder="Put some text here..."
    />
    <BoxView
        HeightRequest="1"
        Color="LightGray"
        VerticalOptions="End"
        Margin="0,0,0,5"
    />
</Grid>

当然可以根据需要进行调整

The accepted answer is really complicated. How about using Grid, Frame, Entry and BoxView like this:

<Grid>
    <Frame Padding="0" />
    <Entry
        Margin="5,0,5,0"
        Placeholder="Put some text here..."
    />
    <BoxView
        HeightRequest="1"
        Color="LightGray"
        VerticalOptions="End"
        Margin="0,0,0,5"
    />
</Grid>

Tweak as needed of course

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文