Reputation: 1148
I don't know how to top the placeholder text in a entry box. I have a entry box that is very big and want to put the placeholder text in the top.
<Entry Placeholder="Enter notes about the item"
Keyboard="Text" VerticalOptions="Start" HeightRequest="80" />
Upvotes: 5
Views: 6782
Reputation: 6007
No need more Customize, only need use in XAML: HorizontalTextAlignment="Center"
Upvotes: -1
Reputation: 4032
You will need to create a custom renderer for each platform to aling the placeholder something like this:
public class PlaceholderEditor : Editor
{
public static readonly BindableProperty PlaceholderProperty =
BindableProperty.Create<PlaceholderEditor, string>(view => view.Placeholder, String.Empty);
public PlaceholderEditor()
{
}
public string Placeholder
{
get
{
return (string)GetValue(PlaceholderProperty);
}
set
{
SetValue(PlaceholderProperty, value);
}
}
}
public class PlaceholderEditorRenderer : EditorRenderer
{
public PlaceholderEditorRenderer()
{
}
protected override void OnElementChanged(
ElementChangedEventArgs<Editor> e)
{
base.OnElementChanged(e);
if (e.NewElement != null)
{
var element = e.NewElement as PlaceholderEditor;
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;
}
}
}
Upvotes: 3