Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AdaptiveGridView OneRowMode height #1614

Merged

Conversation

skendrot
Copy link
Contributor

Issue: #1613

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build or CI related changes
[ ] Documentation content changes
[ ] Sample app changes
[ ] Other... Please describe:

What is the current behavior?

Height of the items does not match the requested height

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Docs have been added / updated (for bug fixes / features)
  • Sample in sample app has been added / updated (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)

What is the new behavior?

Height of items should now match the requested height

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@michael-hawker
Copy link
Member

Original Example:
image

Looks like the behavior has changed with this change. The panel will now take up all the vertical space in one row mode (in the image above the scrollbar is right beneath the images). I have to add VerticalAlignment="Center" to the AdaptiveGridView to make it behave like it did previously.

It's also still clipping by 4 pixels (better than the 14 before though).

You can check by changing the border thickness in the template to 5 and Red:

image

You can see the collapsed scrollbar at the bottom-left without the added vertical alignment.

@michael-hawker
Copy link
Member

Could this be related to the collapsible scrollbars in the platform behaving differently between vertical and horizontal?

In vertical we can see the overlap clipping when the scrollbar is expanded (but it's translucent):

image

But the display isn't disrupted when it's collapsed:

image

Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per above, forgot to make it an actual review, as it was behavioral. Looks like there's a bit more going on here than the simple height change.

@nmetulev nmetulev added this to the v2.2 milestone Nov 20, 2017
@nmetulev
Copy link
Contributor

nmetulev commented Dec 4, 2017

ping @skendrot

@skendrot
Copy link
Contributor Author

skendrot commented Jan 9, 2018

Looks like the border being cut off is from the GridViewItem style being applied

style.Setters.Add(new Setter(MarginProperty, new Thickness(0, 0, 0, 4)));

Setting the Margin to 0 shows the entire element.

@skendrot
Copy link
Contributor Author

skendrot commented Jan 10, 2018

I have a solution that allows for the same ScrollBar behavior as before, but allows to see the entire item. It involves an internal ValueConverter for the MaxHeight binding.

Thoughts on this direction?

        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (value != null)
            {
                var gridView = parameter as AdaptiveGridView;
                if (gridView == null)
                {
                    return value;
                }

                var padding = gridView.Padding;
                int.TryParse(value.ToString(), out int height);

                height = height + (int)padding.Top + (int)padding.Bottom;
                var setter = gridView.ItemContainerStyle.Setters.OfType<Setter>().FirstOrDefault(s => s.Property == FrameworkElement.MarginProperty);
                if (setter != null)
                {
                    var margin = (Thickness)setter.Value;
                    height = height + (int)margin.Top + (int)margin.Bottom;
                }

                return height;
            }

            return value;
        }

@nmetulev
Copy link
Contributor

Looks like you need to update the headers on the new file

@nmetulev
Copy link
Contributor

ping @michael-hawker for his review

@skendrot
Copy link
Contributor Author

skendrot commented Feb 6, 2018

ping @michael-hawker

Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay on this, been swamped the last bit.

Minor thought on access, but tested it out and looks great!


namespace Microsoft.Toolkit.Uwp.UI.Controls
{
internal class AdaptiveHeightValueConverter : IValueConverter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone wants to adapt the adaptive grid view, won't they need access to this?

Should we instead make it public but in a sub-namespace like Microsoft.Toolkit.Uwp.UI.Controls.AdaptiveGridView?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any reason it needs to be public. It's used within a private method. Can always open it at a later date

@skendrot skendrot merged commit 92bb768 into CommunityToolkit:master Feb 7, 2018
@windowstoolkitbot
Copy link

This PR is linked to unclosed issues. Please check if one of these issues should be closed: #1613

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants