Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Multi-column ListView in Grid layout

$
0
0

I don't know if this is a legitimate bug or if I'm misusing the Grid layout, however I cannot seem to be able to have a ListView in a grid that spans more than one column. Is that a library limitation?

Here is a small test code for the Page.GetMainPage() method:

var problematicControl = new ListView { BackgroundColor = Color.Red };
var entry = new Entry { Placeholder = "Entry" };
var button = new Button { Text = "Button" };

var grid = new Grid {
        VerticalOptions = LayoutOptions.Fill,
        RowDefinitions = {
            new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
            new RowDefinition { Height = new GridLength(30, GridUnitType.Absolute) }
        },
        ColumnDefinitions = {
            new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
            new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }
        }
};
grid.Children.Add (problematicControl, 0, 0);
Grid.SetColumnSpan (problematicControl, 2);
grid.Children.Add (entry, 0, 1);
grid.Children.Add (button, 1, 1);

return new ContentPage { Content = grid };

When I do so on iOS, I get a CALayerInvalidGeometry exception with the reason: "CALayer.position contains NaN: [nan -18]" .

However, if problematicControl was a Label instead of a ListView, then everything works just fine. Thoughts?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>