Documentos de Académico
Documentos de Profesional
Documentos de Cultura
INTRODUCCIÓN
Existen diferentes lenguajes de programación orientado a objetos para escribir funciones y
procedimientos pero el C# se acomoda a la necesidad del curso, porque nos va permitir realizar
aplicaciones multiplataforma en móviles con XAMARIN y VISUAL STUDIO 2017
Pág. 1
Aplicaciones Móviles Multiplataforma Layouts
Pág. 2
Aplicaciones Móviles Multiplataforma Layouts
<StackLayout>
<Button x:Name="Item3" Text="Datepicker"/>
<Button x:Name="Item14" Text="ListviewSource"/>
</StackLayout>
<StackLayout Orientation="Horizontal">
<StackLayout>
<Button x:Name="Item1" Text="ButtonDemo"/>
<Button x:Name="Item2" Text="ButtonCode"/>
<Button x:Name="Item4" Text="EditorDemo"/>
<Button x:Name="Item5" Text="EditorCode"/>
<Button x:Name="Item6" Text="EntryDemo"/>
<Button x:Name="Item7" Text="EntryCode"/>
</StackLayout>
<StackLayout>
<Button x:Name="Item8" Text="LabelDemo"/>
<Button x:Name="Item9" Text="LabelCode"/>
<Button x:Name="Item10" Text="LocalImage"/>
<Button x:Name="Item11" Text="EmbeddedImage"/>
<Button x:Name="Item12" Text="ListViewDemo"/>
<Button x:Name="Item13" Text="ListviewCode"/>
</StackLayout>
</StackLayout>
</StackLayout>
</ContentPage>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace Ejercicio03
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
Item1.Clicked += async (sender, e) =>
{
await Navigation.PushAsync(new ButtonDemo());
};
Pág. 3
Aplicaciones Móviles Multiplataforma Layouts
};
Item4.Clicked += async (sender, e) =>
{
await Navigation.PushAsync(new EditorDemo());
};
Item5.Clicked += async (sender, e) =>
{
await Navigation.PushAsync(new EditorCode());
};
Item6.Clicked += async (sender, e) =>
{
await Navigation.PushAsync(new EntryDemo());
};
Item7.Clicked += async (sender, e) =>
{
await Navigation.PushAsync(new EntryCode());
};
Item8.Clicked += async (sender, e) =>
{
await Navigation.PushAsync(new LabelDemo());
};
Item9.Clicked += async (sender, e) =>
{
await Navigation.PushAsync(new LabelCode());
};
Item10.Clicked += async (sender, e) =>
{
await Navigation.PushAsync(new LocalImage());
};
Item11.Clicked += async (sender, e) =>
{
await Navigation.PushAsync(new EmbeddedImage());
};
Item12.Clicked += async (sender, e) =>
{
await Navigation.PushAsync(new ListViewDemo());
};
Item13.Clicked += async (sender, e) =>
{
await Navigation.PushAsync(new ListViewCode());
};
Item14.Clicked += async (sender, e) =>
{
await Navigation.PushAsync(new ListViewSource());
Pág. 4
Aplicaciones Móviles Multiplataforma Layouts
};
}
}
}
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
namespace Ejercicio03
{
public partial class App : Application
{
public App()
{
InitializeComponent();
Pág. 5
Aplicaciones Móviles Multiplataforma Layouts
Button
Agregar una página de contenido de nombre button.xaml
<Label x:Name="label"
Text="Click the Button below"
FontSize="Large"
VerticalOptions="CenterAndExpand"
HorizontalOptions="Center" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
Pág. 6
Aplicaciones Móviles Multiplataforma Layouts
Agregar el código C#
namespace PageDesign
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Button : ContentPage
{
public Button ()
{
InitializeComponent ();
}
async void OnButtonClicked(object sender, EventArgs args)
{
Pág. 7
Aplicaciones Móviles Multiplataforma Layouts
Button Code
Agregar una página de contenido de nombre ButtonCode.xaml
Agregar el código C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Ejercicio03
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ButtonCode : ContentPage
{
public ButtonCode ()
{
InitializeComponent ();
Title = "Code Button Click";
Pág. 8
Aplicaciones Móviles Multiplataforma Layouts
};
button.Clicked += async (sender, args) => await
label.RelRotateTo(360, 1000);
Pág. 9
Aplicaciones Móviles Multiplataforma Layouts
Datepicker
Agregar una página de contenido de nombre DatepickerDemo.xaml
Pág. 10
Aplicaciones Móviles Multiplataforma Layouts
Label
Agregar página de contenido de nombre LabelDemo.xaml
Pág. 11
Aplicaciones Móviles Multiplataforma Layouts
LabelCode
Agregar página de contenido de nombre LabelCode.xaml
Agregar el código C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Ejercicio03
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class LabelCode : ContentPage
{
public LabelCode ()
{
InitializeComponent ();
StackLayout stack = new StackLayout();
var underlineLabel = new Label { Text = "This is underlined text.",
TextDecorations = TextDecorations.Underline };
var strikethroughLabel = new Label { Text = "This is text with
strikethrough.", TextDecorations = TextDecorations.Strikethrough };
var bothLabel = new Label { Text = "This is underlined text with
strikethrough.", TextDecorations = TextDecorations.Underline |
TextDecorations.Strikethrough };
stack.Children.Add(underlineLabel);
stack.Children.Add(strikethroughLabel);
stack.Children.Add(strikethroughLabel);
Pág. 12
Aplicaciones Móviles Multiplataforma Layouts
Content = stack;
}
}
}
Pág. 13
Aplicaciones Móviles Multiplataforma Layouts
Entry
Agregar página de contenido de nombre EntryDemo.xaml
Pág. 14
Aplicaciones Móviles Multiplataforma Layouts
EntryCode
Agregar página de contenido de nombre EntryCode.xaml
Agregar el código C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Ejercicio03
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class EntryCode : ContentPage
{
public EntryCode ()
{
InitializeComponent ();
StackLayout stack = new StackLayout();
var entry = new Entry { Text = "This is a read-only Entry"};
stack.Children.Add(entry);
Content = stack;
}
}
}
Pág. 15
Aplicaciones Móviles Multiplataforma Layouts
Pág. 16
Aplicaciones Móviles Multiplataforma Layouts
Editor
Agregar página de contenido de nombre EditorDemo.xaml
Pág. 17
Aplicaciones Móviles Multiplataforma Layouts
EditorCode
Agregar página de contenido de nombre EditorCode.xaml
Agregar el código C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Ejercicio03
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class EditorCode : ContentPage
{
public EditorCode ()
{
InitializeComponent ();
StackLayout stack = new StackLayout();
var MyEditor = new Editor { Text = "I am an Editor" };
stack.Children.Add(MyEditor);
Content = stack;
}
}
}
Pág. 18
Aplicaciones Móviles Multiplataforma Layouts
LocaI mage
Agregar página de contenido LocalImage.xaml
Pág. 19
Aplicaciones Móviles Multiplataforma Layouts
Modificar xaml
Pág. 20
Aplicaciones Móviles Multiplataforma Layouts
Embedded mage
Agregar página de contenido EmbeddedImage.xaml
Pág. 21
Aplicaciones Móviles Multiplataforma Layouts
Pág. 22
Aplicaciones Móviles Multiplataforma Layouts
Modificar código c#
using System;
using System.Reflection;
using Xamarin.Forms.Xaml;
using Xamarin.Forms;
using Xamarin.Forms.Internals;
namespace Ejercicio03
{
[Preserve(AllMembers = true)]
[ContentProperty(nameof(Source))]
public class ImageResourceExtension : IMarkupExtension
{
public string Source { get; set; }
return imageSource;
}
}
}
Pág. 23
Aplicaciones Móviles Multiplataforma Layouts
Modificar 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"
xmlns:local2="clr-namespace:Ejercicio03"
x:Class="Ejercicio03.EmbeddedImage">
<ContentPage.Content>
<ScrollView>
<StackLayout x:Name="stack">
<Label Text="Embedded Images!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
<Image Source="{local2:ImageResource
Ejercicio03.logotest.jpg}" />
</StackLayout>
</ScrollView>
</ContentPage.Content>
</ContentPage>
Pág. 24
Aplicaciones Móviles Multiplataforma Layouts
Pág. 25
Aplicaciones Móviles Multiplataforma Layouts
Pág. 26
Aplicaciones Móviles Multiplataforma Layouts
Pág. 27
Aplicaciones Móviles Multiplataforma Layouts
Pág. 28
Aplicaciones Móviles Multiplataforma Layouts
Pág. 29
Aplicaciones Móviles Multiplataforma Layouts
Pág. 30