Langkah - Langkah membuat Aplikasi Sederhana Menggunakan Xamarin
1. Membuka Visual Studio dan Install Mobile Development with .NET
2. Pilih Create a new project dan pilih Mobile App (Xamarin,Form)
3. Konfigurasi project
5. Ubah kode pada 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="HelloWorldXamarin.MainPage">
<StackLayout>
<Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0">
<Label Text="Welcome to Xamarin.Forms!" HorizontalTextAlignment="Center" TextColor="White" FontSize="36"/>
</Frame>
<Button Text="Click Me!" Clicked="ClickCounter"/>
<Label Text="Hello, World!" FontSize="Title" Padding="30,10,30,10"/>
<Label Text="Mobile Development With Xamarin" FontSize="16" Padding="30,0,30,0"/>
<Label FontSize="16" Padding="30,24,30,0">
<Label.FormattedText>
<FormattedString>
<FormattedString.Spans>
<Span Text="Learn more at "/>
<Span Text="https://kanarekha.blogspot.com/" FontAttributes="Bold"/>
</FormattedString.Spans>
</FormattedString>
</Label.FormattedText>
</Label>
</StackLayout>
</ContentPage>
6. Ubah kode pada MainPage.xaml.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace HelloWorldXamarin
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
int count = 0;
void ClickCounter(object sender, System.EventArgs e)
{
count++;
((Button)sender).Text = $"You clicked {count} times.";
}
}
}
7.Setup Emulator dan Run Aplikasi di emulator
Source Code : https://github.com/kanarekha/net_HelloXamarin.git
Komentar
Posting Komentar