The MinimumHeightRequest property does not work on a StackLayout

Hello, I would like to know how I can apply a height to a minimum since the MinimumHeightRequest stackLayout property does not work

Best Answer

Answers

  • CraigDunnCraigDunn Xamurai USXamarin Team Xamurai

    What exactly does your StackLayout look like?

  • SebastianCabreraSebastianCabrera USMember

    there I send you an example I am using the MinimumHeightRequest:
    File: WindowPopup.cs
    Line: 83

  • SebastianCabreraSebastianCabrera USMember

    Good day, I wonder if you have seen the example to see that does not work.

    Thank you

  • SebastianCabreraSebastianCabrera USMember

    Is there a reason you just can not use HeightRequest instead of
    MinimumHeightRequest?
      My intention is to create a windowpoup that when there will be if the content of the window is less than a minimum is created with the minimum
    're putting a stack inside of a grid layout.
    Within a cell of a grid I could not put a stackLayout?

    Thanks for your answers.

  • MitchMilamMitchMilam ✭✭✭ USMember ✭✭✭

    yes, you can put a StackLayout inside of a grid (which is how most of us do it, I think). The only issue you have to watch out for is the sizing of the cells vs. the sizing of the contents.

  • SebastianCabreraSebastianCabrera USMember

    Excuse my ignorance, as I really am new issue Xamarin.
    I did not understand means StackLayoutSize <= cellsize?

    Thanks again and sorry for the inconvenience.

  • flchauxflchaux ✭✭ FRMember ✭✭

    I agree with it. Is this a pull request to solve this or a bug report ?

  • MarchevMarchev ✭✭ BGMember ✭✭

    We also bumped into this. Looking at the code I figured that in order for the property to actually contain the minimum height request, this line should be removed:
    minimum.Height = Math.Min(request.Height, minimum.Height);

  • JohnHardmanJohnHardman mod GBUniversity mod
    edited February 2017

    Apparently MinimumHeightRequest and MinimumWidthRequest are not intended to do what us mere mortals think they should do.

    I raised a bug for this a while ago at:
    https://bugzilla.xamarin.com/show_bug.cgi?id=44738

    The response was "While we wish Minimum Width/Height worked differently, such a change now would be a large breaking change to many users and as such will not be fixed". Personally, I reckon most people would prefer the breaking change as what it does now is not what it logically should do (and I don't actually think it would break many dev's code).

    A proposal to do something about it was also rejected, details at:
    https://forums.xamarin.com/discussion/84885/rejected-obsolete-minimum-width-height-request#latest

  • MarchevMarchev ✭✭ BGMember ✭✭

    Thanks, John! The links were helpful for me because they made me realize nothing will change.
    I am curious to see how one is supposed to use the min request properties, because setting them does not seem to make any difference. For what are they good? Does anybody have an example?

  • NMackayNMackay mod GBInsider, University mod

    I don't bother because as John explained, they make no difference. Where possible I use grids and percentage sizing to try and make the UI as device friendly as possible...bit tricky sometimes though in certain scenarios.

  • knottydevknottydev ✭✭ USMember ✭✭

    Again... and this has been my resounding response as a Veteran .NET Engineer just coming into the Mobile World and Xamarin:

    I ask the Xamarin team, what kind of developers you want to focus on? Do you want a community of mostly junior/indie devs who need to be kept "safe" from themselves? Or do you want to provide a feature rich framework with conformity and standardization, that is flexible, scalable and easily considered by enterprise teams?

    You are part of Microsoft now - if anything good comes of that, it should be this.

  • BradChase.2654BradChase.2654 ✭✭✭ USMember ✭✭✭

    I would actually be extremely interested in seeing if anyone actually uses the current public implementation of it? Maybe a vote would be interesting.

  • ChaseFlorellChaseFlorell mod CAInsider, University mod

    @BradChase.2654 I can say with certainty that I've never used Minimum[X]Request ever because it just doesn't do what I want it to do.

    Example

    <ContentView BackgroundColor="White" > 
      <Label HorizontalOptions="FillAndExpand" 
             MinimumHeightRequest="30"
             Margin="6"
             VerticalOptions="Start"
             IsEnabled="False"
             Text="{Binding DataObject.StorageLocation.Notes}" />
    </ContentView>
    

    I would expect this to make the Label a minimum of 30d tall even if there is no text within. What it actually does... Nothing.

  • JohnHardmanJohnHardman mod GBUniversity mod

    I haven't upgraded to XF 3.0 yet. Is it safe to assume Microsoft/Xamarin missed the opportunity of a major version number change to change MinimumHeightRequest and MinimumWidthRequest (either to make them do what we all want them to do, or simply to deprecate them)?

Sign In or Register to comment.