Bug 51412 - On UWP, page's that set Title in OnAppearing rather than in constructor, don't display Title and sometimes Toolbar
Summary: On UWP, page's that set Title in OnAppearing rather than in constructor, don'...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.3.3
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jimmy [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-01-11 15:43 UTC by John Hardman
Modified: 2017-03-09 00:16 UTC (History)
4 users (show)

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


Attachments
repro project (115.88 KB, application/x-zip-compressed)
2017-03-09 00:13 UTC, Jimmy [MSFT]
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 John Hardman 2017-01-11 15:43:44 UTC
On UWP using 2.3.3.180, when pushing a page onto the navigation stack, where that page sets Title in OnAppearing rather than in the page constructor, the page appears without a Title, and on desktop without a toolbar.

If another page is pushed on top, and then popped again, the first page (that didn't initially show a Title and possibly toolbar) now does.

It appears that a workaround is simply to set Title to a dummy value in the page constructor and leave all other code as is.
Comment 1 John Hardman 2017-01-11 15:44:32 UTC
Not sure whether this is related to Bug 51142. It may be, but there isn't enough information on 51142 to be sure either way.
Comment 2 John Hardman 2017-01-11 19:51:57 UTC
This is also a problem on WinRT using 2.3.3.180
Comment 3 Stephane Delcroix 2017-02-15 14:21:46 UTC
sounds legit. please provide a simple repro project

thanks
Comment 4 John Hardman 2017-02-15 17:58:30 UTC
@Stephane Delcroix

Just push the following page onto the navigation stack. On UWP, no title is not displayed. Uncomment the Title in the constructor and then the one in OnAppearing is displayed. The one in OnAppearing should be displayed regardless of whether one was set in the constructor.

using Xamarin.Forms;

namespace ViewsUsingXamarinForms
{
    public class Bug51412PageView : ContentPage
    {
        public Bug51412PageView()
        {
            // If the following line is commented out, the Title in OnAppearing is not displayed.
            //this.Title = "ConstructorTitle";
        }

        protected override void OnAppearing()
        {
            base.OnAppearing();

            this.Title = "OnAppearingTitle";
            this.BackgroundColor = Color.White;
        }

    } // public class Bug51412PageView : ContentPage

} // namespace ViewsUsingXamarinForms

// eof
Comment 5 John Hardman 2017-02-15 17:59:30 UTC
Sorry, that should have said "no title is displayed" rather than "no title is not displayed"
Comment 6 John Hardman 2017-02-15 18:00:57 UTC
I haven't yet worked out precisely under what circumstances a toolbar is not displayed. I'm hoping that finding the cause of the title not being displayed will also identify when the toolbar is not displayed.
Comment 7 Jimmy [MSFT] 2017-03-09 00:13:46 UTC
Created attachment 20230 [details]
repro project

I was able to reproduce this issue with the project I am attaching when using Forms 2.3.3.180. However I tested with Forms 2.3.4-pre2 and the issue seems to be resolved.

It appears to have been fixed with this commit: https://github.com/xamarin/Xamarin.Forms/commit/9572c0f7a7f8c49175853432fe7b61b431e450a1

The Title _is_ set correctly (verified with the Live Visual Tree tool in VS) however the entire title area was not visible due to the the Title being initially null.