Bug 32006 - App crashes on SizeChanged event with focus on a control (Entry)
Summary: App crashes on SizeChanged event with focus on a control (Entry)
Status: RESOLVED NORESPONSE
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.4
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-07-16 05:48 UTC by mehul19851
Modified: 2016-04-11 07:34 UTC (History)
5 users (show)

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

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 NORESPONSE

Description mehul19851 2015-07-16 05:48:43 UTC
The below code takes care of width for a page depending upon Screen Orientation.

*** START CODE ***

portraitView = () => new StackLayout
{
	// Second paramater is to accomodate iPhone status bar.
	Orientation = StackOrientation.Vertical,
	Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 10),
	VerticalOptions = LayoutOptions.FillAndExpand,
	HorizontalOptions = LayoutOptions.Center,
	WidthRequest = MyBase.PageWidth(display.Width, Constants.PORTRAIT_WIDTH),
	Spacing = 10,
	Children = {
				LoginPageContainerGrid
			}
};

landscapeView = () => new StackLayout
{
	// Second paramater is to accomodate iPhone status bar.
	Orientation = StackOrientation.Vertical,
	Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 10),
	VerticalOptions = LayoutOptions.FillAndExpand,
	HorizontalOptions = LayoutOptions.Center,
	WidthRequest = MyBase.PageWidth(display.Width, Constants.LANDSCAPE_WIDTH),
	Spacing = 10,
	Children = {
		LoginPageContainerGrid
	}
};

SizeChanged += (sender, e) => Content = IsPortrait(this) ? portraitView() : landscapeView();

*** END CODE ***


However the above code breaks in the SizeChanged event (i.e. when screen is rotated). Upon debugging the code we found that this issue (SizeChanged event) occurs only when there is Focus on a control (in our case Entry control) and the screen is rotated.

As temporary workaround we have added below code:

// REMOVING FOCUS FROM CONTROL BEFORE ASSIGNING THE CONTENT IN SIZECHANGED EVENT.

*** START CODE ***

SizeChanged += (sender, e) =>
{
	Username.Unfocus(); 

	if (IsPortrait(this))
	{
		Content = portraitView();
	}
	else
	{
		Content = landscapeView();
	}

};

*** END CODE ***


Kindly assist on the same.


Many Thanks & Regards,
Mehul Bhadricha
Comment 1 Chris King 2015-07-31 13:46:41 UTC
Thanks for taking the time to submit this bug. We prioritize bugs with attached reproductions so to expedite investigation of your issue we'd very much appreciate it if you could kindly attach the application in which you observe the issue. If your able to strip out functionality that's not necessary for the reproduction so much the better. 

Warm regards,
XFT
Comment 2 Jason Smith [MSFT] 2016-04-11 07:34:30 UTC
Thank you for your bug report. As we have not received the information requested, we cannot properly triage your bug and are marking it resolved.

Warm regards,
Xamarin Forms Team