我需要将Xamarin Forms应用程序中的自定义呈现器转换为Maui处理程序。
因此,我有一个VisualElementRenderer,如下所示:
[assembly: ExportRenderer(typeof(CardsView), typeof(CardsViewRenderer))]
namespace CardView
{
[Preserve(AllMembers = true)]
public class CardsViewRenderer : VisualElementRenderer<CardsView>
{
}
}
其中CardsView
是从AbsoluteLayout
衍生而来。
现在,我尝试将其转换为Maui,但我无法找到一个VisualElementHandler
来替换VisualElementRenderer
。如果不是这样,我的处理程序将继承自什么,因为我没有一个PlatformView传递到我的ViewHandler,我不确定在这种情况下PlatformView将是什么。
到目前为止,这是我的想法
public partial class CardsViewHandler : ViewHandler<CardsView,??Not sure??>
谢谢你的帮助!
1条答案
按热度按时间xxb16uws1#
我已经检查了源代码,发现没有
AbsoluteLayout
的处理程序。但是AbsoluteLayout
是从Layout
继承的,Layout
有一个LayoutHandler
。当在Maui中创建
Layout
的示例时,LayoutHandler
将返回ViewGroup
(针对android)和UIView
(针对ios)。因此,您可以尝试使用以下第一行代码(针对ios)和第二行代码(针对android)。此外,还可以根据this link在maui中使用自定义渲染器。