I am trying to get a simple TextBoxCell working. I want a label on the left in all platforms to have a consistent layout.
`
public class TextBoxCell : ViewCell
{
private Label label;
private Entry entry;
private StackLayout layout;
public TextBoxCell()
{
this.label = new Label()
{
VerticalOptions = LayoutOptions.Center,
MinimumWidthRequest = 50
};
this.entry = new Entry () {
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.FillAndExpand
};
this.layout = new StackLayout () {
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.Fill,
Padding = new Thickness (15, 0),
Children = {
this.label,
this.entry
}
};
this.View = this.layout;
}
public string Label
{
get { return this.label.Text; }
set { this.label.Text = value; }
}
public string Text
{
get{ return this.entry.Text; }
set { this.entry.Text = value; }
}
public string Placeholder
{
get { return this.entry.Placeholder; }
set { this.entry.Placeholder = value; }
}
}
`
The class is pretty simple as you can see. I want to add some more controls to it to indicate a validation error with an icon on the right eventually.
Right now the issue is that this control works perfectly fine if the Text is initially empty - it displays as expected. The label on the left and the Entry filling the rest of the space to the screen border.
If Text contains a very long text and the screen is opened then the Entry expands past the screen border on iOS.
The TableView in which this is used is pretty straight forward as well:
`
TableView tblSetup = new TableView ();
tblSetup.Intent = TableIntent.Settings;
tblSetup.Root = new TableRoot ();
TableSection tsDisplay = new TableSection ("Display");
tblSetup.Root.Add(tsDisplay);
// note input
this.txtNote = new TextBoxCell () {
Label = "Note ",
Placeholder = "enter a long text",
Text = this.MyNote
};
tsDisplay.Add(this.txtNote);
`
Can anyone help? I played with all the options I could think of for changing the horizontal layout of the Entry, but I always get the same result.
Thanks