Xamarin.forms: MinimumWidthRequest values not honored

Created on 31 May 2018  路  6Comments  路  Source: xamarin/Xamarin.Forms

Description

One would presume that a MinimumWidthRequest = 200 should try to make an element at least 200 wide if the layout space is available. Less if the space is not available. And grow longer if the content extends beyond 200 and the space is available.
That doesn't happen.

Steps to Reproduce

  1. Place an element on a view, such as an Entry
  2. Set the MinimumWidthRequest to 200 or whatever
  3. Run it. The entry will be nearly no width if there is no value

Expected Behavior

should try to make an element at least the specified amount wide if the layout space is available. Less if the space is not available. And grow longer if the content extends beyond the specified amount and the space is available.

Actual Behavior

Nope. Shrink to minimal size like 10

Basic Information

  • Version with issue:
  • Last known good version:
  • IDE:
  • Platform Target Frameworks:

    • iOS:

    • Android:

    • UWP:

  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices:

Screenshots

image

Reproduction Link

All 6 comments

See #2536. For some reason I still fail to understand, the property doesn't do what you would expect it to do. Lots of people have complained about it. However, they Don't want to change the behavior because it would be a breaking change. Therefore I've suggested to deprecate the old properties, and introduce new properties with a slightly different name that actually do what everyone expects. I haven't received any feedback yet though.

Also see https://github.com/xamarin/Xamarin.Forms/issues/1862, I don't think they are going to change it.

@Paul-Brenner-Tangoe I commented on that issue a while back. No reply though

This is not going to be changed, it would be backwards compat breaking. MinimumWidthRequest does not mean the minimum size the control can be. It means how far down the control can squish in overflow scenarios. If the WidthRequest is set lower than it you get undefined behavior.

You want to set WidthRequest.

This issue has been closed for a long time but there continues to be confusion around these properties. I wanted to link to some updated documentation about these properties because this issue and responses are misleading.

The minimum properties do work as expected in my tests but there are some conditions. In this case I believe the fact that no WidthRequest is specified could be causing the width to be less than the MinimumWidthRequest, which has undefined behavior. I have recently expanded this doc with details:

https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/controls/common-properties#minimum-request-properties

Also this setting is currently broken on Grids https://github.com/xamarin/Xamarin.Forms/issues/7303 which probably isn't helping the confusion 馃槙

Was this page helpful?
0 / 5 - 0 ratings