Bug 41344 - ForceUpdateSize doesn't resize when changing the padding of a child layout
Summary: ForceUpdateSize doesn't resize when changing the padding of a child layout
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.4
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-05-26 20:30 UTC by christine.blanda
Modified: 2018-01-12 19:11 UTC (History)
4 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:


Attachments
test project (82.92 KB, application/x-zip-compressed)
2016-05-26 20:30 UTC, christine.blanda
Details
running in android (15.48 KB, image/png)
2016-05-27 18:58 UTC, christine.blanda
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description christine.blanda 2016-05-26 20:30:40 UTC
Created attachment 16114 [details]
test project

I have a ListView with a custom ViewCell called MyTextCell, which contains a _viewLayout (a Horizontal StackLayout) which contains a _nameLayout (a Vertical StackLayout)

If I change the padding on _nameLayout and call ForceUpdateSize the cell does not resize.
If I change the padding on _viewLayout and call ForceUpdateSize the cell does resize.

In the attached test project Item One has the padding added to the _nameLayout and Item Three has the padding added to the _viewLayout.  The padding is not changed for Item Two.  Both the Master and the Detail inflate the same page.
Comment 1 Samantha Houts [MSFT] 2016-05-27 01:39:11 UTC
Can you describe or mock up an example of what you expect it to look like when the cells are resized?

You may find that changing the Margin instead of (or in addition to) the Padding produces your desired result. 

Thank you!
Comment 2 christine.blanda 2016-05-27 11:46:17 UTC
I'm not following your question - I am expecting the cell to re-size taking into account the new padding, regardless of which object the padding is applied to.  

In other words I would expect the cell to have the same height after the padding change and call to ForceUpdateSize as it would if the padding was in the definition of the cell.  

While it seems not to matter which layout contains the padding in this super-simplified example, the example was designed to show the issue in the simplest possible terms, not create a realistic scenario.
Comment 3 Samantha Houts [MSFT] 2016-05-27 18:31:59 UTC
Hm. Well, when I run this example project on Android, I do see both cells resize to take into account the padding. Are you not seeing the cells resize at all? Or are they resizing but not in the way you expected them to?
Comment 4 christine.blanda 2016-05-27 18:57:08 UTC
That is not what I see .. I see that Item 3 has both the padding increased and the Cell Size increased accordingly.  As a result the text is lined up with the carrot and the red "padding" is visible on all 4 sides of the blue label.

Item 1 has the padding increased similarly, but because the Cell Size is not increased  the label moves down in the cell so the full amount of the red top padding is visible, but the bottom of the cell cuts off the bottom red padding so it is not visible.  It should have an equal amount of red padding on the top and bottom, but it doesn't, because the Cell has not re-sized to accommodate the new padding values.  This is even more obvious if you change the background color on the second item by adding the definition in the OnBindingContextChanged event:

                if (!String.IsNullOrEmpty(_descriptionLabel.Text))
                {
                    _descriptionLabel.IsVisible = true;
                    _viewLayout.BackgroundColor = Color.White;
                }

I also increased the new padding to exaggerate the issue a bit more ... the new values are:

                    if (item.Key == 1)
                        _nameLayout.Padding = new Thickness(0, Device.OnPlatform(12, 10, 3));
                    if ( item.Key == 3)
                        _viewLayout.Padding = new Thickness(8, Device.OnPlatform(12, 14, 3));
                    this.ForceUpdateSize();

I'll attach the result I get with these two changes, let me know if this is not what you are seeing.
Comment 5 christine.blanda 2016-05-27 18:58:24 UTC
Created attachment 16124 [details]
running in android
Comment 6 Samantha Houts [MSFT] 2016-05-27 23:41:17 UTC
Thank you for the additional information!
Comment 7 christine.blanda 2017-04-07 18:48:36 UTC
This is still an issue using 2.3.4.224
Comment 8 christine.blanda 2018-01-12 19:11:27 UTC
My tests show this is no longer an issue in 2.5.0 :)