MAUI EntryHandler 不包含 EntryMapper
MAUI EntryHandler does not contain EntryMapper
在 Maui 的预览版 11 左右之前,下面的代码一直有效。但是使用预览版 13 我得到一个编译器错误:'EntryHandler' 不包含 'EntryMapper'.
的定义
PickerMapper 显示了类似的错误。
代码复制自官方文档
#if ANDROID
using Microsoft.Maui.Controls.Compatibility.Platform.Android;
#endif
using Application = Microsoft.Maui.Controls.Application;
namespace myapp;
public partial class App : Application
{
public App(AuthenticationService authenticationService, SyncService syncService)
{
InitializeComponent();
// Remove underline from all pickers and entries in app
#if ANDROID
Microsoft.Maui.Handlers.PickerHandler.PickerMapper.AppendToMapping("NoUnderline", (h, v) =>
{
h.NativeView.BackgroundTintList = Android.Content.Res.ColorStateList.ValueOf(Colors.Transparent.ToAndroid());
});
Microsoft.Maui.Handlers.EntryHandler.EntryMapper.AppendToMapping("NoUnderline", (h, v) =>
{
h.NativeView.BackgroundTintList = Android.Content.Res.ColorStateList.ValueOf(Colors.Transparent.ToAndroid());
});
#endif
MainPage = new AppShell(authenticationService, syncService);
}
}
有人看到解决方案吗?
我一直在高低搜索,但共识似乎是代码是正确的。
我认为所有 EntryMapper
和 PickerMapper
,基本上所有 {Control}Mapper
都重命名为 Mapper
。
此外,我看到您每次升级到预览版 14 时都会引用 NativeView
,这些引用将重命名为 PlatformView
,因此您也必须相应地重命名它们。
在 Maui 的预览版 11 左右之前,下面的代码一直有效。但是使用预览版 13 我得到一个编译器错误:'EntryHandler' 不包含 'EntryMapper'.
的定义PickerMapper 显示了类似的错误。
代码复制自官方文档
#if ANDROID
using Microsoft.Maui.Controls.Compatibility.Platform.Android;
#endif
using Application = Microsoft.Maui.Controls.Application;
namespace myapp;
public partial class App : Application
{
public App(AuthenticationService authenticationService, SyncService syncService)
{
InitializeComponent();
// Remove underline from all pickers and entries in app
#if ANDROID
Microsoft.Maui.Handlers.PickerHandler.PickerMapper.AppendToMapping("NoUnderline", (h, v) =>
{
h.NativeView.BackgroundTintList = Android.Content.Res.ColorStateList.ValueOf(Colors.Transparent.ToAndroid());
});
Microsoft.Maui.Handlers.EntryHandler.EntryMapper.AppendToMapping("NoUnderline", (h, v) =>
{
h.NativeView.BackgroundTintList = Android.Content.Res.ColorStateList.ValueOf(Colors.Transparent.ToAndroid());
});
#endif
MainPage = new AppShell(authenticationService, syncService);
}
}
有人看到解决方案吗?
我一直在高低搜索,但共识似乎是代码是正确的。
我认为所有 EntryMapper
和 PickerMapper
,基本上所有 {Control}Mapper
都重命名为 Mapper
。
此外,我看到您每次升级到预览版 14 时都会引用 NativeView
,这些引用将重命名为 PlatformView
,因此您也必须相应地重命名它们。