Last active
July 31, 2020 11:41
-
-
Save jfversluis/b90f424e57c111e2559b55248a3d25a0 to your computer and use it in GitHub Desktop.
Bindable RowDefinitions in Xamarin.Forms Grid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MainPage.xaml.cs | |
public RowDefinitionCollection MyRows => new RowDefinitionCollection() { | |
new RowDefinition { Height = GridLength.Auto }, | |
new RowDefinition { Height = 100 }, | |
new RowDefinition { Height = GridLength.Star }, | |
new RowDefinition { Height = 50 }, | |
}; | |
public MainPage() | |
{ | |
InitializeComponent(); | |
BindingContext = this; | |
} | |
// MainPage.xaml | |
<?xml version="1.0" encoding="utf-8"?> | |
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="TestSwitch.MainPage"> | |
<Grid RowDefinitions="{Binding MyRows}"> | |
<Frame Grid.Row="0" BackgroundColor="#2196F3" Padding="24" CornerRadius="0"> | |
<Label Text="Welcome to Xamarin.Forms!" HorizontalTextAlignment="Center" TextColor="White" FontSize="36" /> | |
</Frame> | |
<Label Text="1" Grid.Row="1" /> | |
<Label Text="2" Grid.Row="2" /> | |
<Label Text="3" Grid.Row="3" /> | |
</Grid> | |
</ContentPage> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment