Search code examples
xamarin.formsxamarin.androidxamarin.iosxamarin-studio.net-standard

Xamarin forms visual studio for Mac clean-namespace problem


I have created a Xamarin forms application using .net standard. Then I added a .net standard library project to the solution that will include common codes such as renders, behaviours etc. I include the reference of common .net standard library project to the main Xamarin forms project by right clicking on dependencies and Edit References menu. Finally I try to include the namespace of renderer files on the content page of main Xamarin forms by specifying the below line using Xamarin.Forms;

namespace MyProject.Shared.Renderer
{
    public class ExtendedEntry : Entry
    {
        public static readonly BindableProperty IsBorderErrorVisibleProperty = BindableProperty.Create(nameof(IsBorderErrorVisible), typeof(bool), typeof(ExtendedEntry),
            false, BindingMode.TwoWay);

        public bool IsBorderErrorVisible
        {
            get { return (bool)GetValue(IsBorderErrorVisibleProperty); }
            set { SetValue(IsBorderErrorVisibleProperty, value); }
        }

        public static readonly BindableProperty BorderErrorColorProperty = BindableProperty.Create(nameof(BorderErrorColor), typeof(Color), typeof(ExtendedEntry),
            null, BindingMode.TwoWay);

        public Color BorderErrorColor
        {
            get { return (Color)GetValue(BorderErrorColorProperty); }
            set { SetValue(BorderErrorColorProperty, value); }
        }

        public static readonly BindableProperty ErrorTextProperty = BindableProperty.Create(nameof(ErrorText), typeof(string), typeof(ExtendedEntry), string.Empty,
            BindingMode.TwoWay);

        public string ErrorText
        {
            get { return (string)GetValue(ErrorTextProperty); }
            set { SetValue(ErrorTextProperty, value); }
        }
    }
}
xmlns:controls=“clr-namespace:MyProject.Shared.Renderer:assembly:MyProject.Shared”

Then I reference the control as
<controls:ExtendedEntry />

But this gives build error that says ExtendedEntry is not found in the assembly MyProject.Shared

Please help


Solution

  • Sorry...I had done blunder...a real blunder.

    I typed ":" instead of "=" in assembly attribute.

    It should be xmlns:controls=“clr-namespace:MyProject.Shared.Renderer:assembly=MyProject.Shared”