Forum Xamarin.Forms

GridLength.Zero

mshibanamimshibanami USMember
edited February 2017 in Xamarin.Forms

Summary

Add a static property Zero to GridLength class.

API Changes

It will work like this:

GridLength.Zero.Equals(new GridLength(0)); // true

I think this property can be implemented very easily. Just add this on here:

public static GridLength Zero
{
    get { return new GridLength(0, GridUnitType.Absolute); }
}

Intended Use Case

new GridLength(0) can be useful if we want to hide some Grid's rows or columns.
https://forums.xamarin.com/discussion/17552/how-to-hide-a-row-or-column-in-a-grid-layout

So I think it would be nice if we could use it on the plain XF.

Tagged:

Open · Last Updated

Posts

  • AdrianKnightAdrianKnight USMember ✭✭✭✭

    Wondering if this should be named AbsoluteZero since the underlying representation is in absolute terms.

    Compare this to:

    new GridLength(0, GridUnitType.Auto)
    new GridLength(0, GridUnitType.Star)
    
  • CharlesRoddieCharlesRoddie USMember ✭✭

    A good implementation would be
    GridLength as a 2D vector space of floats, with the first component being absolute, the second relative.
    Final layout length = absolute + k * relative, where k * sum of relatives = total - sum of absolutes.
    Then have sums and GridLength.Zero

Sign In or Register to comment.