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

Custom Entry Renderer stopping app compiling

$
0
0

I've added a custom entry renderer following this guide: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/entry

These are my classes:

MyEntry.cs in the shared project:

using Xamarin.Forms;

namespace CrossPlatformApp
{
    public class MyEntry : Entry
    {
    }
}

CustomRenderer.cs in .Android

using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Text;
using Android.Graphics;

using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

using CrossPlatformApp;
using CrossPlatformApp.Droid;

[assembly: ExportRenderer(typeof(MyEntry), typeof(MyEntryRenderer))]
namespace CrossPlatformApp.Droid
{
    class MyEntryRenderer : EntryRenderer
    {
        public MyEntryRenderer(Context context) : base(context)
        {
        }

        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                this.Control.InputType = InputTypes.ClassText | InputTypes.TextFlagCapSentences;
                Control.Background.SetColorFilter(Android.Graphics.Color.DarkSlateBlue, PorterDuff.Mode.SrcAtop);
            }
        }
    }
}

CustomRenderer.cs in the .iOS project

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using CrossPlatformApp;
using CrossPlatformApp.iOS;

using Foundation;
using UIKit;

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

[assembly: ExportRenderer(typeof(MyEntry), typeof(MyEntryRenderer))]
namespace CrossPlatformApp.iOS
{
    public class MyEntryRenderer : EntryRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {

            }
        }
    }
}

CustomRenderer.cs in the .UWP project

using CrossPlatformApp.UWP;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Platform.UWP;

[assembly: ExportRenderer(typeof(MyEntry), typeof(MyEntryRenderer))]
namespace CrossPlatformApp.UWP
{
    public class MyEntryRenderer : EntryRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
              //  Control.Background = new SolidColorBrush(Colors.Cyan);
            }
        }
    }
}

The .Android class is fine, there are no errors and I've been testing it and changing the code in it fine. However, in the .iOS and .UWP classes, I have an error on the line [assembly: ExportRenderer(typeof(MyEntry), typeof(MyEntryRenderer))]

The error is under '(MyEntry)', it says "The type or namespace name 'MyEntry' could not be found. (Are you missing a using directive or assembly?)

Why would this not be working for iOS and UWP but be fine for Android? As far as I can remember, I didn't add any references to the .Android project, and I've therefore I've not added any to either of the other projects - but would the issue be that I am supposed to add a reference?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>