如何将VisualElementRenderer从XF转换为Maui Handlers



我的Xamarin Forms应用程序中有一个自定义渲染器,我需要将其转换为Maui Handler。

所以我有一个VisualElementRenderer,它如下所示:

[assembly: ExportRenderer(typeof(CardsView), typeof(CardsViewRenderer))]
namespace CardView
{
[Preserve(AllMembers = true)]
public class CardsViewRenderer : VisualElementRenderer<CardsView>
{
}
}

其中CardsView是从AbsoluteLayout导出的。

现在,我正试图将其转换为毛伊岛,但我找不到可以取代VisualElementRendererVisualElementHandler。如果不是这样的话,我的处理程序继承自什么,因为我没有PlatformView可以传递到我的ViewHandler中,我不确定在这种情况下PlatformView会是什么。

到目前为止,这就是我提出的

public partial class CardsViewHandler : ViewHandler<CardsView,??Not sure??>

谢谢你的帮助!

我检查了reosurce代码,发现没有AbsoluteLayout的处理程序。但是CCD_ 6是从具有CCD_ 8的CCD_。

当Maui中的Layout的实例创建时,LayoutHandler将为android返回ViewGroup,为ios返回UIView。因此,您可以尝试为ios使用以下第一行代码,为android使用第二行代码。

public partial class CardsViewHandler : ViewHandler<CardsView,LayoutView>
//LayoutView is inherited from the MauiView which is inherited from the UIKit.UIView
public partial class CardsViewHandler : ViewHandler<CardsView,LayoutGroup>
//LayoutGroup is inherited from Android.Views.ViewGroup

此外,您还可以根据此链接使用maui中的自定义渲染器。

最新更新