Bug 52425 - The second column of a Grid is not aligned to the right if so told when there are many components
Summary: The second column of a Grid is not aligned to the right if so told when there...
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS ()
Version: 2.3.4
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jimmy [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-02-09 17:35 UTC by Dimitar Dobrev
Modified: 2017-03-02 17:15 UTC (History)
2 users (show)

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


Attachments
repro project (12.11 KB, application/zip)
2017-03-01 21:51 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 NOT_REPRODUCIBLE

Description Dimitar Dobrev 2017-02-09 17:35:16 UTC
I have this page:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:Invent.GUI;assembly=Invent.GUI"
             x:Class="Invent.GUI.FinishInventoryPage">
	<Grid>
		<Image Source="background.png" Aspect="AspectFill" />
		<StackLayout Spacing="10">
			<Label Text="{local:Localise InventorySummary}" Margin="0, 20, 0, 0" HorizontalOptions="Center" />
			<Label Text="{Binding Location.FullName}" HorizontalOptions="Center" />
			<Grid Margin="30, 0, 30, 0">
				<Label Text="{local:Localise Found}" />
				<Label Text="{local:Localise Missing}" Grid.Row="1" />
				<Label Text="{local:Localise External}" Grid.Row="2" />
				<Label Text="{Binding FoundAssetsCount}" Grid.Column="1" HorizontalOptions="End" />
				<Label Text="{Binding ExternalAssetsCount}" Grid.Row="1" Grid.Column="1" HorizontalOptions="End" />
				<Label Text="{Binding MissingAssetsCount}" Grid.Row="2" Grid.Column="1" HorizontalOptions="End" />
			</Grid>
			<Label Text="{local:Localise Note}" Margin="30, 5, 0, 5" />
			<Editor x:Name="editorNote" VerticalOptions="FillAndExpand" Margin="30, 0, 30, 0" />
			<Button Text="{local:Localise Cancel}" HorizontalOptions="Fill" Margin="30, 0, 30, 0" Clicked="ButtonCancel_Clicked" />
			<Button Text="{local:Localise Save}" HorizontalOptions="Fill" Margin="30, 0, 30, 0" Clicked="ButtonSave_Clicked" />
			<Button Text="{local:Localise Complete}" HorizontalOptions="Fill" Margin="30, 0, 30, 10" Clicked="ButtonComplete_Clicked" />
		</StackLayout>
	</Grid>
</ContentPage>

Never mind the "Localise" mark-up extension and the bindings, using hard-coded strings works just as well.
The elements in the second column of the Grid are configured to align to the right but they don't, at least on a simulator of iPhone 4s with iOS 9.0. If a single component, such as one of the buttons, is removed, then it works correctly. So does the following workaround, posted here for your reference:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:Invent.GUI;assembly=Invent.GUI"
             x:Class="Invent.GUI.FinishInventoryPage">
	<Grid>
		<Image Source="background.png" Aspect="AspectFill" />
		<StackLayout Spacing="10">
			<Label Text="{local:Localise InventorySummary}" Margin="0, 20, 0, 0" HorizontalOptions="Center" />
			<Label Text="{Binding Location.FullName}" HorizontalOptions="Center" />
			<!--HACK: much better to use a Grid here but there's a bug causing the second column not to be aligned to the right-->
			<StackLayout Orientation="Horizontal" Margin="30, -5, 30, 0">
				<Label Text="{local:Localise Found}" />
				<Label Text="1" HorizontalOptions="EndAndExpand" />
			</StackLayout>
			<StackLayout Orientation="Horizontal" Margin="30, -10, 30, 0">
				<Label Text="{local:Localise Missing}" />
				<Label Text="1" HorizontalOptions="EndAndExpand" />
			</StackLayout>
			<StackLayout Orientation="Horizontal" Margin="30, -10, 30, 0">
				<Label Text="{local:Localise External}" />
				<Label Text="1" HorizontalOptions="EndAndExpand" />
			</StackLayout>
			<Label Text="{local:Localise Note}" Margin="30, 5, 0, 5" />
			<Editor x:Name="editorNote" VerticalOptions="FillAndExpand" Margin="30, 0, 30, 0" />
			<Button Text="{local:Localise Cancel}" HorizontalOptions="Fill" Margin="30, 0, 30, 0" Clicked="ButtonCancel_Clicked" />
			<Button Text="{local:Localise Save}" HorizontalOptions="Fill" Margin="30, 0, 30, 0" Clicked="ButtonSave_Clicked" />
			<Button Text="{local:Localise Complete}" HorizontalOptions="Fill" Margin="30, 0, 30, 10" Clicked="ButtonComplete_Clicked" />
		</StackLayout>
	</Grid>
</ContentPage>

I haven't checked if it works with the stable 2.3.3 because I need 2.3.4 because of Frame.CornerRadius.
Comment 1 Jimmy [MSFT] 2017-03-01 21:50:03 UTC
I created a sample project based on the code provided, but I was not able to see the issue described. I ran the app on an iOS 9.1 iPhone 4s and iOS 10.3 iPhone 7 simulator and the second appeared to be right aligned: https://www.dropbox.com/s/p7njz5an67sykbi/Screenshot%202017-03-01%2013.37.24.png?dl=0

### Versions
Forms 2.3.3.180     GOOD
Forms 2.3.4-pre2    GOOD

Can you share a screenshot of what you are seeing? I'm attaching the project I used to test with, do you experience the issue with this project? If possible, can you attach a repro project so we can look into this further? Thanks!
Comment 2 Jimmy [MSFT] 2017-03-01 21:51:18 UTC
Created attachment 20074 [details]
repro project
Comment 3 Dimitar Dobrev 2017-03-02 09:18:12 UTC
Jimmy, thank you for trying this one yourself. The overwhelming majority of your colleagues ask for a sample right away without trying themselves first. I am afraid, however, that I used the workaround to solve my problem and I don't have the time to test this now. I'll write a new comment here as soon as I have tested it.
Comment 4 Jimmy [MSFT] 2017-03-02 17:15:11 UTC
I understand, and I will mark this report as NOT_REPRODUCIBLE in the meantime. When you get the chance to test it, you can re-open the report and we'll take another look. Thanks!