Quantcast
Channel: User Liyun Zhang - MSFT - Stack Overflow
Viewing all articles
Browse latest Browse all 445

Answer by Liyun Zhang - MSFT for How to add adornments postfix to Maui xaml enty element?

$
0
0

You can custom a such control by yourself.

The custom control(you can declare it as a contentview):

<Border BackgroundColor="LightBlue"><Border.StrokeShape><RoundRectangle CornerRadius="40"/></Border.StrokeShape><Grid ColumnDefinitions="8*,2*" BackgroundColor="Transparent"><Entry BackgroundColor="Transparent" Grid.Column="0"/><Label Text="test" BackgroundColor="Transparent" Grid.Column="1" VerticalTextAlignment="Center" HorizontalTextAlignment="Center"/></Grid></Border>

And then disable the entry's underline and border:

For the android and ios, add the following code in the App.cs's constructor:

Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping("NoBorder", (h, v) =>            {#if ANDROID                h.PlatformView.BackgroundTintList = Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Transparent);#elif IOS                h.PlatformView.BorderStyle = UIKit.UITextBorderStyle.None;#endif            });

And for the windows platform, add the following code in the App.xaml below the Platforms/Windows folder.

<maui:MauiWinUIApplication.Resources><Thickness x:Key="TextControlBorderThemeThickness">0</Thickness><Thickness x:Key="TextControlBorderThemeThicknessFocused">0</Thickness></maui:MauiWinUIApplication.Resources>

Viewing all articles
Browse latest Browse all 445

Trending Articles



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