4
votes

I'm trying to create a custom renderer for an advert

using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
using FreeFallCalculator.Controls;
using FreeFallCalculator.Models;
using Xamarin.Forms.Internals;

[assembly: ExportRenderer(typeof(AdControlView), typeof(AdViewRenderer))]
namespace FreeFallCalculator.Models
{
    class AdViewRenderer
    {

    }
}

It keeps giving me this error when trying to compile:

Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'ExportRendererAttribute' could not be found (are you missing a using directive or an assembly reference?)

2
Is the renderer in the Droid or ios project? It looks like it isn't. That is where the ExportRenderer attribute is generally used. - Steve Chadbourne
it's also a little weird to have a Renderer in a "Models" namespace - Jason

2 Answers

2
votes

The custom renderer should be in the platform specific project.

0
votes

And your ClassRenderer you need inherit PageRendererthen:

class AdViewRenderer: PageRenderer //never forget
{

}

this for each platform