Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A comparison between classic C#, C# markup, and XAML for creating UI
var grid = new Grid();
var label = new Label { Text = "Code:" };
grid.Children.Add(label, 0, 1);
var entry = new Entry
{
Placeholder = "Enter number",
Keyboard = Keyboard.Numeric,
BackgroundColor = Color.AliceBlue,
TextColor = Color.Black,
FontSize = 15,
HeightRequest = 44,
Margin = 20
};
grid.Children.Add(entry, 0, 2);
Grid.SetColumnSpan(entry, 2);
entry.SetBinding(Entry.TextProperty, new Binding("RegistrationCode"));
Content = grid;
Content = new Grid {
Children = {
new Label { Text = "Code:" }.Row(1),
new Entry {
Placeholder = "Enter number",
Keyboard = Keyboard.Numeric,
BackgroundColor = Color.AliceBlue,
TextColor = Color.Black
}
.Font(15)
.Row(2)
.ColumnSpan(2)
.Margin(20)
.Height(44)
.Bind("RegistrationCode")
}};
Content = new Grid
{
Children = {
new Label { Text = "Code:" }
.Row(1),
new Entry {
Placeholder = "Enter number",
Keyboard = Keyboard.Numeric,
BackgroundColor = Color.AliceBlue,
TextColor = Color.Black
}
.Font(15)
.Row(2)
.ColumnSpan(2)
.Margin(20)
.Height(44)
.Bind("RegistrationCode")
}
};
Content = new Grid {
Children = {
new Label { Text = "Code:" }.Row(1),
new Entry {
Placeholder = "Enter number",
Keyboard = Keyboard.Numeric,
BackgroundColor = Color.AliceBlue,
TextColor = Color.Black,
FontSize = 15,
HeightRequest = 44,
Margin = 20
}
.Row(2)
.ColumnSpan(2)
.Bind("RegistrationCode")
}};
<ContentPage.Content>
<Grid>
<Label Grid.Row="1" Text="Code:" />
<Entry
Grid.Row="1"
Grid.ColumnSpan="2"
Margin="20"
BackgroundColor="AliceBlue"
FontSize="15"
HeightRequest="44"
Keyboard="Numeric"
Placeholder="Enter number"
Text="{Binding RegistrationCode}"
TextColor="Black" />
</Grid>
</ContentPage.Content>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment