Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting HeightRequest back to Auto in Xamarin.Forms

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?

like image 951
James Mundy Avatar asked Feb 17 '17 15:02

James Mundy


1 Answers

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.

like image 195
James Mundy Avatar answered Oct 22 '22 02:10

James Mundy