0% found this document useful (0 votes)
114 views2 pages

Label: Visual Studio

The document demonstrates different Xamarin.Forms UI controls including Label, Button, Entry, Image and Grid. Label is used to display text, Button handles click events, Entry allows text input, Image displays images from URLs or resources, and Grid lays out controls in a table-like format. Properties like text, colors, sizes can be set and events handled for the different controls.

Uploaded by

Ricardo Fonzalez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
114 views2 pages

Label: Visual Studio

The document demonstrates different Xamarin.Forms UI controls including Label, Button, Entry, Image and Grid. Label is used to display text, Button handles click events, Entry allows text input, Image displays images from URLs or resources, and Grid lays out controls in a table-like format. Properties like text, colors, sizes can be set and events handled for the different controls.

Uploaded by

Ricardo Fonzalez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Visual Studio

Label
<StackLayout Margin="20,35,20,20">
<Label Text="Welcome to Xamarin.Forms!"
HorizontalOptions="Center" />
</StackLayout>

<Label Text="Welcome to Xamarin.Forms!"


TextColor="Blue"
FontAttributes="Italic"
FontSize="22"
TextDecorations="Underline"
HorizontalOptions="Center" />

Button
<StackLayout Margin="20,35,20,20">
<Button Text="Click me" />
</StackLayout>

<Button Text="Click me"


Clicked="OnButtonClicked" />

void OnButtonClicked(object sender, EventArgs e)


{
(sender as Button).Text = "Click me again!";
}

<Button Text="Click me"


Clicked="OnButtonClicked"
TextColor="Blue"
BackgroundColor="Aqua"
BorderColor="Red"
BorderWidth="5"
CornerRadius="5"
WidthRequest="150"
HeightRequest="75" />

Entry
<StackLayout Margin="20,35,20,20">
<Entry Placeholder="Enter text" />
</StackLayout>

<Entry Placeholder="Enter text"


TextChanged="OnEntryTextChanged"
Completed="OnEntryCompleted" />

void OnEntryTextChanged(object sender, TextChangedEventArgs e)


{
string oldText = e.OldTextValue;
string newText = e.NewTextValue;
}

void OnEntryCompleted(object sender, EventArgs e)


{
string text = ((Entry)sender).Text;
}

Image
<StackLayout Margin="20,35,20,20">
<Image
Source="http://upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Papio_anubis_%28Serengeti
%2C_2009%29.jpg/200px-Papio_anubis_%28Serengeti%2C_2009%29.jpg"

Aspect="Fill"
HeightRequest="{OnPlatform iOS=300, Android=250}"
WidthRequest="{OnPlatform iOS=300, Android=250}"
HorizontalOptions="Center" />
</StackLayout>

https://docs.microsoft.com/en-us/xamarin/get-started/tutorials/image/images/vs/android-resource.png
<Image Source="XamarinLogo"
WidthRequest="{OnPlatform iOS=300, Android=250}"
HorizontalOptions="Center" />

Grid
<Grid Margin="20,35,20,20">
<Label Text="The Grid has its Margin property set, to control the rendering
position of the Grid." />
</Grid>

<Grid Margin="20,35,20,20">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition Width="0.5*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<Label Text="Column 0, Row 0" />
<Label Grid.Column="1"
Text="Column 1, Row 0" />
<Label Grid.Row="1"
Text="Column 0, Row 1" />
<Label Grid.Column="1"
Grid.Row="1"
Text="Column 1, Row 1" />
</Grid>

You might also like