Bug 22673 - Initially hidden BoxView when made visible does not render (but does take up space in the UI)
Summary: Initially hidden BoxView when made visible does not render (but does take up ...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.2.2
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 1.3.4
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-09-05 01:13 UTC by Adrian
Modified: 2015-10-13 13:12 UTC (History)
16 users (show)

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


Attachments
Xamarin.Forms Page that shows problem (861 bytes, application/octet-stream)
2014-09-05 01:13 UTC, Adrian
Details
Screenshot of problem with box view when shown (154.22 KB, image/tiff)
2014-09-05 01:17 UTC, Adrian
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 Adrian 2014-09-05 01:13:31 UTC
Created attachment 7939 [details]
Xamarin.Forms Page that shows problem

If a BoxView is initially hidden (i.e. IsVisible = false) and then shown it does not get visually rendered but does take up space in the UI.

Attached is an App.cs Xamarin.Forms page which demonstrates the problem, it has an initially hidden box view, a button to show the hidden box view, and underneath another box view which is initially visible just to prove that box views are working.

When the button is clicked the button and box view underneath the button both get moved down the screen to make space for the box view above but the newly shown box view does not get visually rendered.

Workaround: The box view needs to be assigned a different colour before it is made visible and it will be visually rendered as below:

showButton.Clicked += (sender, args) =>
{
  hiddenBoxView.Color = Color.Blue;
  hiddenBoxView.IsVisible = true;
};

This is potentially a problem if you have a binding to the box view colour in your view model as this then fires a property change when there isn't one.
Comment 1 Adrian 2014-09-05 01:17:30 UTC
Created attachment 7940 [details]
Screenshot of problem with box view when shown
Comment 2 Arpit Jha 2014-09-08 02:38:45 UTC
I have checked this issue and able to reproduce it.

Steps to reproduce 
Create a xamarin forms application and  followed above bug description.

I observed that at first when  we set boxview   IsVisible to false then Boxview doesn't take space  in UI  as expected but when we set boxview Isvisible to true  then boxview took space  in UI and doesn't render.

Screencast regarding same : http://screencast.com/t/GUAgoyUy

Environment Info:

=== Xamarin Studio ===

Version 5.3 (build 440)
Installation UUID: 2591d519-875d-4afe-a3d9-5fcf391bbd2d
Runtime:
	Mono 3.8.0 ((no/45d0ba1)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 308000009

=== Apple Developer Tools ===

Xcode 4.6.3 (2068)
Build 4H1503

=== Xamarin.Mac ===

Version: 1.11.0.1 (Enterprise Edition)

=== Xamarin.iOS ===

Version: 7.4.0.108 (Enterprise Edition)
Hash: 77efa3f
Branch: 
Build date: 2014-08-26 07:59:55-0400

=== Xamarin.Android ===

Version: 4.16.0 (Enterprise Edition)
Android SDK: /Users/nischal/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		3.2    (API level 13)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		4.5    (API level 21)
Java SDK: /usr
java version "1.6.0_35"
Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)

=== Build Information ===

Release ID: 503000440
Git revision: accb55419539e512cff857b14b80ec3107996511
Build date: 2014-09-01 08:53:05-04
Xamarin addins: 6dbac4b3a32df080bf98cde838ce89e573a92859

=== Operating System ===

Mac OS X 10.7.4
Darwin nischals-Mac-mini.local 11.4.0 Darwin Kernel Version 11.4.0
    Mon Apr  9 19:32:15 PDT 2012
    root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64
Comment 3 Subha 2014-10-24 07:57:04 UTC
I am also facing similar problem. My BoxView is initially hidden and then on click of button I am toggling the visibility property of BoxView. Its working fine on Android, but in iOS its not rendering the view, but occupying the space, exactly as reported above.

My environment: 

OS X Version : 10.9.5
Xamarin Studio : 5.0.1 (build 3)
Xamarin.Forms : 1.2.3.6 (pre 4)

When this will be fixed?
Comment 4 Fredy Wenger 2014-11-05 06:31:01 UTC
Same Problem here!
As Workaround, I have tried to add the VISIBLE BoxView in a StackLayout and then make the StackLayout visible and invisible.
This ALSO DON'T WORK!
So, it seems as there is NO WORKAROUND for this Problem yet.
=> Is this bug solved in the next release?
Comment 5 Fredy Wenger 2014-11-05 06:56:11 UTC
Update to Workaround:
- Use Frame instead BoxView seems to work.
Comment 6 Chase Florell 2015-02-02 15:43:32 UTC
I am also seeing this issue.
Comment 7 Jason Smith [MSFT] 2015-02-02 15:52:53 UTC
Should be fixed in 1.3.3-pre1
Comment 8 Chase Florell 2015-02-02 15:53:35 UTC
 fyi, for me, it's fine in Android, but has issues in iOS.
Comment 9 Chase Florell 2015-02-02 15:53:48 UTC
Oh awesome, thanks Jason.
Comment 13 Jason Smith [MSFT] 2015-02-06 14:06:15 UTC
Found the bug, its been around FOREVER so its not technically a regression, as such going to stick it in 1.3.4
Comment 14 PJ 2015-02-06 14:25:31 UTC
> going to stick it in 1.3.4

-> 1.3.4
Comment 15 Eric Maupin 2015-02-06 15:02:19 UTC
Should be fixed in 1.3.4-pre1
Comment 16 Ram Chandra 2015-02-10 04:03:54 UTC
I have checked this issue with following builds:

Xamarin.Forms: 1.3.4.6325-pre1
Mac OS X 10.10.0
Xamarin Studio: 5.7.1 (build 17)
Installation UUID: 6ea47b0d-1852-4aaf-808d-373ff0a5002b
Mono 3.12.0 ((detached/a813491)
GTK+ 2.24.23 (Raleigh theme)
Package version: 312000068
Xcode 6.1 (6604)
Build 6A1052d
Xamarin.iOS: 8.6.1.20 (Business Edition)
=== Build Information ===
Release ID: 507010017
Git revision: 0bc7d3550b6b088ac25b08dcf7bbe73bcc8658b3
Build date: 2015-02-03 19:43:29-05
Xamarin addins: f7b7d34419c9ec24501bfa7c658e80a6305613e0

Observation : When I set boxview "Isvisible" property to true then boxview took space in UI and rendered on UI perfectly.

Screencast: http://www.screencast.com/t/h98vY6tpeZ

This issue has been fixed. Hence  I am closing this issue.
Comment 17 TJ Wood 2015-07-28 16:34:47 UTC
In 1.4.4, this appears to have regressed.
Comment 18 Simon Taylor 2015-08-10 02:04:25 UTC
Still broken in 1.5.0-pre1.
Comment 19 Simon Taylor 2015-08-17 00:23:38 UTC
Adding an empty derived BoxView class and renderer as below makes the view appear. I'm sure the SetNeedsDisplay() doesn't need to be called quite this often.


using Oban.Mobile.View;

[assembly: ExportRenderer(typeof(ObanBoxView), typeof(Oban.Mobile.iOS.Renderer.ObanBoxRenderer))]

namespace Oban.Mobile.iOS.Renderer
{
    public class ObanBoxRenderer : BoxRenderer
    {
        protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);
            this.SetNeedsDisplay();
        }
    }
}
Comment 20 John Przyborski 2015-08-20 13:48:15 UTC
Setting the BackgroundColor OnBindingContextChanged seems to make the BoxView appear. 

What is interesting, is that this works:
this.Separator.BackgroundColor = Color.FromRgba(0, 0, 0, 50); 

However, this does not:
this.Separator.BackgroundColor = Color.FromRgba(0, 0, 0, 51);

It seems the color values determine whether or not the Boxview’s background is set.
Comment 21 Josh Evenson 2015-09-22 16:24:52 UTC
Still experiencing a similar issue to this, although the behavior is different across iOS and Android using Xamarin Forms.

I've attached a BoxViewTest.zip which contains an Xamarin Forms solution. When you launch the app, click the button toggle visibility of the content view. 

On Android, it will behave as expected. But on iOS, you will need to click the button three times before the red box view will appear.

This only works because I invert the IsVisible state from the ContentView AND the BoxView inside of it. The BoxView's IsVisible property should by default inherit from the parent (in this case the content view).

If you remove this line of code from the button click event, neither OSes will work.

bv.IsVisible = !bv.IsVisible;
Comment 22 Josh Evenson 2015-09-22 16:49:04 UTC
https://github.com/jevenson/BoxViewTest

Here is the solution
Comment 23 Josh Evenson 2015-09-22 18:23:43 UTC
This is using Xamarin Forms v1.4.4.6392
Comment 24 Josh Evenson 2015-09-22 18:25:59 UTC
Still an issue with v1.5.0.6446
Comment 25 Rui Marinho 2015-10-13 13:12:21 UTC
This is fixed in 1.5.0.6454