Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Is it possible to override a XLabs custom renderer?

$
0
0

It seems like this should be possible, but I can't get it to work. I want to create a custom render for ExtendedViewCell that will be used instead of the ExtendedViewCellRenderer that is already in the assembly. I would think that I can just add the ExportRenderer attribute to my renderer and it should work.

Is there something I'm missing in the assembly registration that causes Xamarin Forms to only recognize the renderer from the XLabs.Forms assembly? Possibly a precedence of some sort?

This is the renderer I'm trying to create:

using Xamarin.Forms.Platform.iOS;
using UIKit;
using XLabs.Forms.Controls;
using Xamarin.Forms;
using MyApp.Views;

[assembly: ExportRenderer(typeof(ExtendedViewCell), typeof(InternalExtendedViewCellRenderer))]

namespace MyApp.Views
{
    public class InternalExtendedViewCellRenderer : ExtendedViewCellRenderer
    {
        public override UITableViewCell GetCell(Xamarin.Forms.Cell item, UITableViewCell reusableCell, UITableView tv)
        {
            var formsCell = item as ExtendedViewCell;

            var cell = base.GetCell(item, reusableCell, tv);

            cell.SelectedBackgroundView = new UIView() { BackgroundColor = formsCell.BackgroundColor.ToUIColor() };

            return cell;
        }
    }
}

Viewing all articles
Browse latest Browse all 58056

Trending Articles