xamarin/Xamarin.Forms

Xamarin.Forms Grid.SetRowSpan(xxx,2) issue

Open

#9,097 opened on Jan 6, 2020

 (2 comments) (0 reactions) (0 assignees)C# (1,926 forks)batch import
a/layoutfeedback-tickethelp wantedinactives/unverifiedt/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

This issue has been moved from a ticket on Developer Community.


This is the section of xaml I am using on a form, where I define the layout in code behind.

The codebehind sets the Grid. When I use the following it displays on the device I am testing on as screenshot 1.

void SetupLandscapeLayout() { grid. RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); grid. RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });

grid. ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid. ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid. ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid. ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid. ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid. ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid. ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid. ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid. ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });

grid. Children.Add(view: labelType, 0, 0); //Grid.SetRowSpan(labelType, 2); grid. Children.Add(view: interactionType, 1, 0); Grid.SetRowSpan(interactionType, 2); Grid.SetColumnSpan(interactionType, 3);

When I un-comment the labelType RowSpan I get screenshot 2.

I have reduced the code to the minimum trying to find what is wrong (overlapping fields etc) but cannot find any reason it is failing.

I have similar code running correctly elsewhere in the same app which works fine, although I have had instances where the expected layout dowsn't happen for some reason, but nothing as blatant as this


Original Comments

Visual Studio Feedback System on 12/16/2019, 02:17 AM:


Original Solutions

(no solutions)

Contributor guide