Bug 59391 - Using an Entry with HorizontalOptions = CenterAndExpand, the Entry does not resize as content grows
Summary: Using an Entry with HorizontalOptions = CenterAndExpand, the Entry does not r...
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.4.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-09-11 14:20 UTC by John Hardman
Modified: 2017-09-11 16:10 UTC (History)
2 users (show)

Tags: all, entry, binding, HorizontalOptions, ac
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 59391 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description John Hardman 2017-09-11 14:20:46 UTC
On Android, iOS and UWP, using XF 2.3.4.267, an Entry with HorizontalOptions = LayoutOptions.CenterAndExpand does not resize as the text in the Entry grows.

To reproduce, add the code below to a project and push a new instance of EntryNotResizingBugPageView onto the navigation stack. Press the button to extend the text, which I would expect to grow the Entry. It doesn't.

Possibly related to confirmed bug 28618



using System.ComponentModel;

using Xamarin.Forms;

namespace ViewsUsingXamarinForms
{
	public class EntryNotResizingBugViewModel : INotifyPropertyChanged
	{
		private string _textValue = "0";
		public string TextValue
		{
			get => _textValue;
			set
			{
				_textValue = value;
				SetPropertyChanged(nameof(TextValue));
			}
		}

		public event PropertyChangedEventHandler PropertyChanged = delegate { }; // TODO - investigate warning here re hiding base class event

		internal void SetPropertyChanged(string propertyName)
		{
			PropertyChanged?.Invoke(
				this, new PropertyChangedEventArgs(propertyName));
		}
	};

	public class EntryNotResizingBugPageView : ContentPage
	{
		public EntryNotResizingBugPageView()
		{
			EntryNotResizingBugViewModel viewModel = new EntryNotResizingBugViewModel();

			this.BindingContext = viewModel;

			Entry entry = new Entry
			{
				HorizontalOptions = LayoutOptions.CenterAndExpand,
				BackgroundColor = Color.White,
				TextColor = Color.Black,
			};

			entry.SetBinding(
				Entry.TextProperty,
				new Binding(
					nameof(EntryNotResizingBugViewModel.TextValue),
					BindingMode.OneWay,
					null,
					null,
					null));

			this.Content = new StackLayout
			{
				Margin = new Thickness(20, 0, 20, 0),
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.Start,
				Children =
				{
					new Button()
					{
						HorizontalOptions = LayoutOptions.FillAndExpand,
						Text = "Press to extend entry text",
						BackgroundColor = Color.White,
						TextColor = Color.Black,
						Command = new Command(() =>
						{
							viewModel.TextValue = viewModel.TextValue + "000";
						})
					},
					entry
				}
			};
		}

	} // public class EntryNotResizingBugPageView : ContentPage

} // namespace ViewsUsingXamarinForms

// eof
Comment 1 Paul DiPietro [MSFT] 2017-09-11 16:10:22 UTC
Updating to reflect that the issue occurs on 2.4.0-pre2 using the above code.