How can i make a border color for Editor in Xamarin.Forms?
I used this link, but it works only for Android. I want it to work in all platforms!
I\'m a little
in your portable project add this control
public class PlaceholderEditor : Editor
{
public static readonly BindableProperty PlaceholderProperty =
BindableProperty.Create("Placeholder", typeof(string), typeof(string), "");
public PlaceholderEditor()
{
}
public string Placeholder
{
get
{
return (string)GetValue(PlaceholderProperty);
}
set
{
SetValue(PlaceholderProperty, value);
}
}
}
in your android project add this renderer:
[assembly: ExportRenderer(typeof(PlaceholderEditor), typeof(PlaceholderEditorRenderer))]
namespace Tevel.Mobile.Packages.Droid
{
public class PlaceholderEditorRenderer : EditorRenderer
{
public PlaceholderEditorRenderer() { }
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (e.NewElement != null)
{
var element = e.NewElement as PlaceholderEditor;
this.Control.Background = Resources.GetDrawable(Resource.Drawable.borderEditText);
this.Control.Hint = element.Placeholder;
}
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == PlaceholderEditor.PlaceholderProperty.PropertyName)
{
var element = this.Element as PlaceholderEditor;
this.Control.Hint = element.Placeholder;
}
}
}
}
in your Resources > drawable add an XML file borderEditText.xml
-
-
Xaml:
Header - xmlns:ctrls="clr-namespace:my control namespace;assembly= my assembly"
control: