Bug 60453 - Content properties changes doesnt render when changed in MasterPage
Summary: Content properties changes doesnt render when changed in MasterPage
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.5.0
Hardware: PC Windows
: Normal blocker
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-10-31 13:51 UTC by Björn Bentmar
Modified: 2018-02-12 18:26 UTC (History)
4 users (show)

Tags: masterdetailpage, layout, wrap, ac
Is this bug a regression?: Yes
Last known good build: 2.3.5 pre 6


Attachments
repro (2.26 MB, application/x-zip-compressed)
2017-10-31 13:51 UTC, Björn Bentmar
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 ANSWERED

Description Björn Bentmar 2017-10-31 13:51:26 UTC
Created attachment 25517 [details]
repro

Its hard to describe this bug with a title...

Info:

Start the app with a masterDetail page set to mainpage. In the masterPage you can toggle visibility on a stacklayout and add text to a label.

Expected Results:
-The stacklayout that contains an image and label will be hidden/show.
- The Label will start wordwrapping when the text gets longer.


Actual result:
-Works fine

Now set the MasterDetailPage.Master to a new instance (Page) And do the same thing.

Actual result:
-Visibility doesnt change anymore.
- Text doesnt wrap as it gets longer.

NOW, if you rotate the device to landscape and back, it works as it should (until you change master page again).

This occurs when your content in the masterpage is wrapped in a scrollview.

I have only tested this on Android. The bug started from 2.4.0-pre1. It worked as it should on previous versions. I have tested this on different devices both pre an post lollipop, no difference.

Try the repro app, it has all the instructions in it.

Please include a fix for this as a service release to 2.4.0
Comment 1 Björn Bentmar 2017-10-31 13:52:34 UTC
My system:

Microsoft Visual Studio Enterprise 2017 
Version 15.4.1
VisualStudio.15.Release/15.4.1+27004.2005
Microsoft .NET Framework
Version 4.7.02046

Installed Version: Enterprise

Azure Data Lake Node   1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio   2.2.9000.1
Microsoft Azure Data Lake Tools for Visual Studio

Azure Data Lake Tools for Visual Studio   2.2.9000.1
Microsoft Azure Data Lake Tools for Visual Studio

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

EMDKProfileManagerWizardVS   1.0
EMDK for Xamarin

Fabric.DiagnosticEvents   1.0
Fabric Diagnostic Events

JavaScript Language Service   2.0
JavaScript Language Service

Merq   1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Azure HDInsight Azure Node   2.2.9000.1
HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service   2.2.9000.1
Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio   1.8
Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service   2.2.9000.1
Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node   1.0
Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.50719.1

Microsoft Continuous Delivery Tools for Visual Studio   0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Mono Debugging for Visual Studio   4.7.4-pre (c2d89eb)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   4.4.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

SettingsWindow Extension   1.0
SettingsWindow Visual Studio Extension Detailed Info


Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

VisualStudio.IoT   1.0
Package with IoT components for Visual Studio

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

Xamarin   4.7.10.22 (fe36bec)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK   8.0.0.33 (HEAD/7a6a056e8)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   11.2.0.8 (9a9f054)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Comment 2 Björn Bentmar 2017-10-31 14:31:26 UTC
Last known good build is 2.3.5pre6
Comment 3 Björn Bentmar 2017-11-15 12:53:15 UTC
by doing this

  private void ResetContent()
        {
            var content = Content;
            Content = null;
            Content = content;
        }

on the new masterpage, it starts to work again. Maybe that helps to find out whats wrong
Comment 4 Fernando 2017-12-06 16:51:14 UTC
Hi Björn,

I have a similar case, and tested your ResetContent() method on a device with Android 4.2, and it did not fix the problem. Running on newer devices like Nougat, it works as expected.

Upon further analysis, I think that the problem has something involved with the HorizontalOptions of the ScrollView inside a MasterDetailPage. In my tests, I have a MasterDetailPage and my Detail page has a ScrollView setted as the Content of the page, with some StackLayouts inside, besides another components (Labels, Images, etc).

If we redefine the HorizontalOptions from the Page.Content (to any value) and the HorizontalOptions from the ScrollView (to anything diferent from Fill / FillAndExpand, like CenterAndExpand), the content will appear correctly in any API version that I have tested. 

But there is a implication with this workaround, I think that when we add some components inside the Content of the ScrollView or inside the Content of any of its children (like StackLayouts), the widths of them all may be recalculated and the bug comes back (hiding some controls), so its important that you define these HorizontalOptions AFTER you add any components that you need.

In my case, I have a ScrollView and in my constructor I set it as the Content of the Detail page. After that, terminating another method where I add some more controls inside the ScrollView, I have to redefine both the HorizontalOptions:

myScrollView.HorizontalOptions = LayoutOptions.CenterAndExpand;
this.Content.HorizontalOptions = LayoutOptions.FillAndExpand;

Doing this, all controls visibility works as expected in any API version.

Hope that it can help!
Comment 5 Samantha Houts [MSFT] 2018-02-12 18:26:35 UTC
This issue has been migrated to https://github.com/xamarin/Xamarin.Forms/issues/1332. Please follow that issue for updates. Thanks!