我正在尝试在 MAUI 中自定义一个条目。主要目的是禁用边框和下划线。这是我当前在 MauiProgram.cs 文件中的代码:
Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping(nameof(MdeEntry), (handler, view) =>
{
#if ANDROID
handler.PlatformView.SetBackgroundColor(Android.Graphics.Color.Transparent);
#elif WINDOWS
//handler.PlatformView.Background = Colors.Transparent.ToPlatform();
//handler.PlatformView.BorderThickness = new Microsoft.UI.Xaml.Thickness(0);
//handler.PlatformView.GotFocus += (s, e) =>
//{
// handler.PlatformView.Background = new Microsoft.UI.Xaml.Media.SolidColorBrush(Microsoft.UI.Colors.Transparent);
// handler.PlatformView.BorderThickness = new Microsoft.UI.Xaml.Thickness(0);
// handler.PlatformView.BorderBrush = new Microsoft.UI.Xaml.Media.SolidColorBrush(Microsoft.UI.Colors.Red);
//};
#endif
});
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,注释代码 - 是我解决问题的尝试,并且所有这些 Windows 代码都不起作用。但是,这个 Android 版可以按照我想要的方式工作:
#if ANDROID
handler.PlatformView.SetBackgroundColor(Android.Graphics.Color.Transparent);
Run Code Online (Sandbox Code Playgroud)
有人知道如何禁用 Windows 上的边框和下划线吗?