示例#1
0
        public static IVisualElementRenderer CreateRenderer(VisualElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException(nameof(element));
            }

            IVisualElementRenderer renderer = null;

            // temporary hack to fix the following issues
            // https://github.com/xamarin/Xamarin.Forms/issues/13261
            // https://github.com/xamarin/Xamarin.Forms/issues/12484
            if (element is RadioButton tv && tv.ResolveControlTemplate() != null)
            {
                renderer = new DefaultRenderer();
            }

            if (renderer == null)
            {
                renderer = Registrar.Registered.GetHandlerForObject <IVisualElementRenderer>(element) ??
                           new DefaultRenderer();
            }

            renderer.SetElement(element);
            return(renderer);
        }
示例#2
0
文件: Platform.cs 项目: lhx11187/maui
        public static IVisualElementRenderer CreateRenderer(VisualElement element)
        {
            IVisualElementRenderer renderer = null;

            if (element is TemplatedView tv && tv.ResolveControlTemplate() != null)
            {
                renderer = new DefaultRenderer();
            }

            if (renderer == null)
            {
                renderer = Internals.Registrar.Registered.GetHandlerForObject <IVisualElementRenderer>(element) ?? new DefaultRenderer();
            }

            renderer.SetElement(element);
            return(renderer);
        }
示例#3
0
        internal static IVisualElementRenderer CreateRenderer(VisualElement element, Context context)
        {
            IVisualElementRenderer renderer = null;

            // temporary hack to fix the following issues
            // https://github.com/xamarin/Xamarin.Forms/issues/13261
            // https://github.com/xamarin/Xamarin.Forms/issues/12484
            if (element is RadioButton tv && tv.ResolveControlTemplate() != null)
            {
                renderer = new DefaultRenderer(context);
            }

            if (renderer == null)
            {
                renderer = Registrar.Registered.GetHandlerForObject <IVisualElementRenderer>(element, context)
                           ?? new DefaultRenderer(context);
            }

            renderer.SetElement(element);
            return(renderer);
        }
示例#4
0
        public static IVisualElementRenderer CreateRenderer(VisualElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException(nameof(element));
            }

            IVisualElementRenderer renderer = null;

            if (element is TemplatedView tv && tv.ResolveControlTemplate() != null)
            {
                renderer = new DefaultRenderer();
            }

            if (renderer == null)
            {
                renderer = Registrar.Registered.GetHandlerForObject <IVisualElementRenderer>(element) ??
                           new DefaultRenderer();
            }

            renderer.SetElement(element);
            return(renderer);
        }