Hello,
I am porting some Xamarin code into .NET MAUI and I received the following error message error messages on lines 21, line 22, line 33, line 34, line 44 and line 50: -
Error CS0234 The type or namespace name 'GetRenderer' does not exist in the namespace 'Microsoft.Maui.Controls.Compatibility.Platform' (are you missing an assembly reference?)
using Rg.Plugins.PopupMaui.iOS.Renderers;
using Rg.Plugins.PopupMaui.Pages;
using UIKit;
using Microsoft.Maui.Controls.Compatibility.Platform.iOS;
using Rg.Plugins.PopupMaui.Extensions;
using OnPlatform = Microsoft.Maui.Controls.Compatibility.Platform;
namespace Rg.Plugins.PopupMaui.iOS.Extensions
{
internal static class PlatformExtension
{
private static bool IsiOS13OrNewer => UIDevice.CurrentDevice.CheckSystemVersion(13, 0);
public static IVisualElementRenderer GetOrCreateRenderer(this VisualElement bindable)
{
var renderer = OnPlatform.GetRenderer(bindable); //CS0234 error
if (renderer == null)
{
renderer = OnPlatform.CreateRenderer(bindable); //CS0234 error
OnPlatform.SetRenderer(bindable, renderer); //CS0234 error
}
return renderer;
}
public static void DisposeModelAndChildrenRenderers(this VisualElement view)
{
IVisualElementRenderer renderer;
#pragma warning disable CS0618 // Type or member is obsolete
foreach (var child in view.RgDescendants().OfType<VisualElement>())
{
renderer = OnPlatform.GetRenderer(child); //CS0234 error
OnPlatform.SetRenderer(child, null); //CS0234 error
if (renderer == null)
continue;
renderer.NativeView.RemoveFromSuperview();
renderer.Dispose();
}
#pragma warning restore CS0618 // Type or member is obsolete
renderer = OnPlatform.GetRenderer(view); //CS0234 error
if (renderer != null)
{
renderer.NativeView.RemoveFromSuperview();
renderer.Dispose();
}
OnPlatform.SetRenderer(view, null); //CS0234 error
}
Kindly help me to fix the CS0234 error messages