Mando
Mando

Reputation: 11712

Custom renderer at Xamarin.Forms could find a OnElementChanged method

I'm trying to implement custom label and iOS renderer for it using Xamarin.Forms. For some reason code from sample is using method which is not in a base class:

OnElementChanged

enter image description here

Any ideas how to fix?

Upvotes: 5

Views: 4177

Answers (4)

MADANI H
MADANI H

Reputation: 1

You have to use ElementChangedEventArgs < AdMobView > as parameter

Upvotes: 0

troYman
troYman

Reputation: 1808

With me, it worked after an update of the Xamarin.Forms Library in the NUGET Package Manager. But you have to use ElementChangedEventArgs<> as Parameter type

Upvotes: 2

Mando
Mando

Reputation: 11712

It turned out that Xamarin.Forms SDK referenced by project template by default is not enough. You have to install additionally NUGET package Xamarin.Forms for your Touch Project:

enter image description here

Upvotes: 5

SKall
SKall

Reputation: 5234

Change the argument type to ElementChangedEventArgs

using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

namespace XForms.Toolkit.iOS.Controls
{
    public class MyLabelRenderer : LabelRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
        {
            base.OnElementChanged(e);
        }
    }
}

Upvotes: 5

Related Questions