28

In Xamarin.Forms I want to be able to set the exact height for a control whose height is initially determined using VerticalLayoutOptions only (FillAndExpand in this case) and then, at a later point, reset the height of the control back to be automatically determined.

In normal XAML it is possible to do this via double.Nan but performing the following causes an exception to be thrown.:

control.HeightRequest = double.NaN

How do you set the HeightRequest back to be self-determined?

James Mundy
  • 4,180
  • 6
  • 35
  • 58

1 Answers1

44

After some investigation it seems rather than using double.NaN Xamarin.Forms uses the value "-1". Using the following sets the control to automatically determine it's own height again:

control.HeightRequest = -1;

Problem solved but hopefully Xamarin will update this so it uses the normal XAML way soon.

James Mundy
  • 4,180
  • 6
  • 35
  • 58