Obsolete minimum width/height request

AdrianKnightAdrianKnight USMember ✭✭✭✭
edited December 2016 in Xamarin.Forms

Summary

Is there any use for MinimumWidth/HeightRequest? According to this thread, they do not function as expected and will not be fixed because the fix would represent a big breaking change. If this is the case, can we mark these properties obsolete so that people don't have to waste time trying to use them only to find out they don't work?

API changes

The following will be obsolete:

MinimumWidthRequestProperty
MinimumHeightRequestProperty
MinimumWidthRequest
MinimumHeightRequest

Intended use case

For anyone who expects these to work. If they don't work, then the APIs should not encourage us to use them.

Tagged:

Rejected · Last Updated

Posts

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    They serve a function still. A more accurate description of the problem is they are poorly named.

    Most people interpret it to mean "The minimum size the control can ever be and no smaller ever" where the actual intent of the property is "the smallest size the control can be squished to when the desired size cannot be met"

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    In other words, people are using the property to try to make their controls bigger. Minimum requests only ever can make things smaller, never bigger. It makes sense when you understand it but long term we've learned the name confuses some people.

  • AdrianKnightAdrianKnight USMember ✭✭✭✭

    I'd say the name confuses most people. Why not rename the properties then?

  • JohnHardmanJohnHardman GBUniversity mod

    Definitely confuses me. If it isn't going to be fixed to do what anybody looking at the name would expect it to do, it should be marked Obsolete and a new property with a more appropriate name added.

    Regarding "the smallest size the control can be squished to when the desired size cannot be met" - how would one go about letting a Button size using just HorizontalOptions and VerticalOptions, but never being smaller than the minimum specified in the UI guidelines? I don't want to go to the hassle of calculating appropriate HeightRequest and WidthRequest, I just want to set MinimumHeightRequest and MinimumWidthRequest to the minimums specified in the UI guidelines.

  • BradChase.2654BradChase.2654 USMember ✭✭✭
    edited December 2016

    I for one would LOVE a true MinimumHeightRequest and MinimumWidthRequest be added. There are plenty examples in control building and creation where you are not entirely sure what the user will do with the control and these help with guidelines and outlines.

  • CharlesRoddieCharlesRoddie USMember ✭✭

    @BradChase.2654 said:
    I for one would LOVE a true MinimumHeightRequest and MinimumWidthRequest be added. There are plenty examples in control building and creation where you are not entirely sure what the user will do with the control and these help with guidelines and outlines.

    Agreed. Whatever alternative names these must have for backwards compatibility reasons, we need the actual features of minimum requests.

  • BradChase.2654BradChase.2654 USMember ✭✭✭
    @CharlesRoddie I am guessing XAML Standard might force some hands on this one.
  • PaulVrugt.3467PaulVrugt.3467 USMember ✭✭
    edited March 2018

    @TheRealJasonSmith said:
    In other words, people are using the property to try to make their controls bigger. Minimum requests only ever can make things smaller, never bigger. It makes sense when you understand it but long term we've learned the name confuses some people.

    Even after the explanation I still don't understand what the property does. It might be true that it makes sense when you understand it, but I doubt anyone does.

    The documentation (https://developer.xamarin.com/api/property/Xamarin.Forms.VisualElement.MinimumHeightRequest/) of the property states:
    Gets or sets a value which overrides the minimum height the element will request during layout.

    and

    The minimum height the element requires. Default value is -1.

    Both of these statements imply that it does what normal people would expect, avoid the element to become smaller than the given value, but allows it to grow larger. I really think there is hardly anyone who uses this property, since nobody understands it.

    It seems to me this is a case of stubbornness of the xamarin.forms developers to not change the property to an implementation that people actually expect, or at least create new properties that do.

  • JohnHardmanJohnHardman GBUniversity mod

    @DavidOrtinau - I think I may have drawn this to your attention previously elsewhere in the forums, but just in case that's a figment of my imagination, could you review this one please?

  • DerProgrammiererDerProgrammierer DEMember ✭✭✭
    edited April 2018

    @PaulVrugt.3467 said:

    @TheRealJasonSmith said:
    In other words, people are using the property to try to make their controls bigger. Minimum requests only ever can make things smaller, never bigger. It makes sense when you understand it but long term we've learned the name confuses some people.

    Even after the explanation I still don't understand what the property does. It might be true that it makes sense when you understand it, but I doubt anyone does.

    The documentation (https://developer.xamarin.com/api/property/Xamarin.Forms.VisualElement.MinimumHeightRequest/) of the property states:
    Gets or sets a value which overrides the minimum height the element will request during layout.

    and

    The minimum height the element requires. Default value is -1.

    Both of these statements imply that it does what normal people would expect, avoid the element to become smaller than the given value, but allows it to grow larger. I really think there is hardly anyone who uses this property, since nobody understands it.

    It seems to me this is a case of stubbornness of the xamarin.forms developers to not change the property to an implementation that people actually expect, or at least create new properties that do.

    After Jason Smith's explanation, I think it should be named MaximumHeightRequest. That's how I understand it now:

    HeightRequest = 28
    MinimumHeightRequest = 20

    In this case, the control would get a height of 20.

    But I completely agree with you and I can only speak for the xamarin developers in our company. No one uses it and if it was ever used in our app, it was used in the perception that it works like most people think it works, leading to wrong layouts when we didn't test this particular piece of code well enough.

    I think it should be set to obsolete and giving an info that soon it's going to be replaced by MaximumHeightRequest. Then, after some months, finally rename it. Give people some additional time (couple months) to change their broken code (which suggests in the obsolete warning to use MaximumHeightRequest). Then, add MinimumHeightRequest again which now does what most people think it does.

  • SteveShaw.5557SteveShaw.5557 USMember ✭✭✭
    edited June 2018

    @DerProgrammierer - If its name were MaximumHeightRequest, then it would ensure that the control never got bigger than the value provided. That is not at all what it does.

    A name that actually describes what it does might be:
    MinimumHeightToShrinkToButOnlyIfTheContentWantsALargerHeightButCantHaveIt!!!

    (What's a non-confusing short name for this concept? I have no idea.)

    That is, it has no effect if there is an abundance of layout room. It only kicks in if the content, in total, requests more height than is available. Then something has to give. This prevents the view it is attached to from shrinking below that height. But if it didn't need that much height to begin with, then there is nothing that needs to be done, so nothing is done.

    So in your example, the view gets height of 28, if there is enough room. If there isn't enough room, then all the controls on page are "squeezed", but this one won't be squeezed below 20. Hence "Minimum" in the name. The final height could be anywhere between 20 and 28.

    An example that shows how the property is useful, would be a view whose size is dynamically computed (or at least non-obvious) based on what it is bound to, and might or might not be taller than 20. Then it takes the space it wants, if it can get it. Whatever amount that is. Unless it needs to be squeezed.

    OTOH, I definitely agree with everyone here that a true "MinimumHeight" ["Be at least this tall"] would be another useful property to have.

  • HelenMamalakiHelenMamalaki GBUniversity ✭✭

    @SteveShaw.5557 said:
    @DerProgrammierer - If its name were MaximumHeightRequest, then it would ensure that the control never got bigger than the value provided. That is not at all what it does.

    A name that actually describes what it does might be:
    MinimumHeightToShrinkToButOnlyIfTheContentWantsALargerHeightButCantHaveIt!!!

    (What's a non-confusing short name for this concept? I have no idea.)

    That is, it has no effect if there is an abundance of layout room. It only kicks in if the content, in total, requests more height than is available. Then something has to give. This prevents the view it is attached to from shrinking below that height. But if it didn't need that much height to begin with, then there is nothing that needs to be done, so nothing is done.

    So in your example, the view gets height of 28, if there is enough room. If there isn't enough room, then all the controls on page are "squeezed", but this one won't be squeezed below 20. Hence "Minimum" in the name. The final height could be anywhere between 20 and 28.

    An example that shows how the property is useful, would be a view whose size is dynamically computed (or at least non-obvious) based on what it is bound to, and might or might not be taller than 20. Then it takes the space it wants, if it can get it. Whatever amount that is. Unless it needs to be squeezed.

    OTOH, I definitely agree with everyone here that a true "MinimumHeight" ["Be at least this tall"] would be another useful property to have.

    How about MinimumShrinkSize? lol literally anything is better than MinimumHeightReuest

Sign In or Register to comment.