Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

TUTORIAL INTRODUCION A XAMARI PRIMERA PARTE

MAINPAGE.XAML
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XamlSamples.MainPage">

<StackLayout>
<!--Place new controls here-->
<Label Text="Welcome to Xamarin Forms"
VerticalOptions="CenterAndExpand"
HorizontalOptions="Center"/>
</StackLayout>

</ContentPage>

MAINPAGE.XAML.CS

namespace XamlSamples
{

public partial class MainPage : ContentPage


{
public MainPage()
{
InitializeComponent();

}
}
}
HELLOXAMLPAGE.XAML

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XamlSamples.HelloXamlPage"
Title="Hello XAML Page">

<ContentPage.Content>
<Label Text="Hello, XAML!"
VerticalOptions="Center"
HorizontalOptions="Center"
Rotation="-15"
IsVisible="true"
FontSize="Large"
FontAttributes="Bold"
TextColor="Blue"/>

</ContentPage.Content>
</ContentPage>

APP.XAML.CS

namespace XamlSamples
{
public partial class App : Application
{
public App()
{
InitializeComponent();

MainPage = new NavigationPage(new MainPage());


}

protected override void OnStart()


{
}

protected override void OnSleep()


{
}

protected override void OnResume()


{
}
}
}
MAINPAGE.XAML.CS

namespace XamlSamples
{

public partial class MainPage : ContentPage


{
public MainPage()
{
InitializeComponent();

Button button = new Button


{
Text = "Navigate!",
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
};

button.Clicked += async (sender, args) =>


{
await Navigation.PushAsync(new HelloXamlPage());
};

Content = button;

}
}
}
XAMLPLUSCODEPAGE.XAML

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XamlSamples.XamlPlusCodePage"
Title="XAML + Code Page">

<StackLayout>
<Slider VerticalOptions="CenterAndExpand"
ValueChanged="OnSliderValueChanged"/>

<Label x:Name="valueLabel"
Text="A Simple Label"
Font="Large"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand"/>

<Button Text="Click Me!"


HorizontalOptions="Center"
VerticalOptions="CenterAndExpand"
Clicked="OnButtonClicked"/>

</StackLayout>

</ContentPage>

APP.XAML.CS
{
public partial class App : Application
{
public App()
{
InitializeComponent();

MainPage = new NavigationPage(new MainPage());


MainPage = new XamlPlusCodePage();
}

protected override void OnStart()


{
}

protected override void OnSleep()


{
}

protected override void OnResume()


{
}
}
}

You might also like