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
Here's the complete solution I used. You need three things.
1 - A custom class that implements Editor
in your forms project.
public class BorderedEditor : Editor
{
}
2 - A custom renderer for your custom Editor
in your iOS project.
public class BorderedEditorRenderer : EditorRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Editor> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.Layer.CornerRadius = 3;
Control.Layer.BorderColor = Color.FromHex("F0F0F0").ToCGColor();
Control.Layer.BorderWidth = 2;
}
}
}
3 - An ExportRenderer
attribute in your iOS project that tells Xamarin to use your custom renderer for your custom editor.
[assembly: ExportRenderer(typeof(BorderedEditor), typeof(BorderedEditorRenderer))]
Then use your custom editor in Xaml:
<custom:BorderedEditor Text="{Binding TextValue}"/>
You will need to implement a Custom Renderer
(guide from Xamarin) for each platform since customizing the BorderColor
of an Entry
is not yet supported in Xamarin.Forms
.
Since you've already managed to change the BorderColor
on Android, you can find a solution for iOS here: http://forums.xamarin.com/discussion/comment/102557/#Comment_102557