[Bug] Grid.Children missing Add convenience methods
See original GitHub issueDescription
Error:
error CS1501: No overload for method 'Add' takes 3 arguments
Code:
var grid = new Microsoft.Maui.Controls.Layout2.GridLayout
{
RowSpacing = 0,
ColumnSpacing = 0,
RowDefinitions =
{
new RowDefinition(),
new RowDefinition(),
new RowDefinition()
},
ColumnDefinitions =
{
new ColumnDefinition(),
new ColumnDefinition(),
new ColumnDefinition()
}
};
grid.Children.Add(new BoxView
{
Color = Color.DarkSlateBlue
}, 2, 1);
I see now that you cannot do RowDefinitions/ColumnDefinitions that way anymore? And you cannot add views to Children.
grid.Add(new BoxView
{
Color = Color.LightSkyBlue
});
That ^ also doesn’t allow 3 args.
Basic Information
- Version with issue: Preview 3
Workaround
Use the Add methods off Grid instead of Grid.Children.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Understanding unique keys for array children in React.js
Each of the dynamic data rows has a unique key assigned to it but I'm still getting an error of: Each child in...
Read more >GridLayout
A layout that places its children in a rectangular grid. ... Convenience method for sending a AccessibilityEvent#TYPE_ANNOUNCEMENT AccessibilityEvent to ...
Read more >Angular Data Grid: Cell Renderer
Cell Renderer. Below is an example of cell renderer class: import {Component} from "@angular/core"; import {ICellRendererAngularComp} from 'ag-grid-angular' ...
Read more >GridPane (JavaFX 8)
Convenience method for placing the specified nodes sequentially in a given column of the gridpane. void, addRow(int rowIndex, Node... children). Convenience ...
Read more >Auto-Sizing Columns in CSS Grid: `auto-fill` vs `auto-fit`
I'll add the column into the row, and it will wrap into a new row on smaller viewports.” In the case where there...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can workaround this for now by calling SetRow/Column explicitly:
The cast is necessary because of this:
The API docs are wrong at this point. There were taken from Forms and not updated for .NET MAUI yet.
It seems that we have a replacement for the 3 argument overload. It’s not done on the
Grid.Children
anymore, but you can do it onGrid
directly. So:Grid.Add(new Label(), 1, 1);
.The 5 arguments overload is provided in a PR here and we’re discussing if this is something we want to take in as it seems a bit of a confusing API.