Hello,
Welcome to our Microsoft Q&A platform!
To set data binding to the RowDefinition property, please create a parameter of RowDefinitionCollection type. Then add instances of RowDefinition with the desired Height to the collection.
Check the code:
//page.xaml
<Grid RowDefinitions="{Binding MyRows}">
<Label Text="row_1" Grid.Row="0"/>
<Label Text="row_2" Grid.Row="1"/>
<Label Text="row_3" Grid.Row="2"/>
<Label Text="row_4" Grid.Row="3"/>
</Grid>
//page.xaml.cs
public partial class TestPage : ContentPage
{
public RowDefinitionCollection MyRows { get; set; }
public TestPage()
{
InitializeComponent();
MyRows = new RowDefinitionCollection() {
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = 50 },
new RowDefinition { Height = GridLength.Star },
new RowDefinition { Height = 100 }
};
BindingContext = this;
}
}
Best Regards,
Jarvan Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.