1. Mes Premiers Pas avec Xamarin
Mohamed BOURAOUI
Bourawi.mohamed@gmail.com
2. Que c’est « Cross-Plateform »
MobileWeb / Hybrid App
Native API to iOS
•HTML5 / JavaScript
Native API to Android
•HTML5/JavaScript
Native API to Windows Phone
•HTML5 / JS
Native Mobile Plateforms
Objective-C, Swift
•XCode
Java
•Android Studio
C#, VB…
•Visual Studio
Cross Plateform avec Xamarin
C# , Visual Studio,
Xamatin Studio
C# , Visual Studio, Xamatin
Studio
C# , Visual Studio, Xamatin
Studio
3. C’est Quoi ce « Xamarin » ?
Xamarin = Développer en C# + Un outil pour les compiler tous
4. On est où … ?
• SDK Manager ?
• AVD Manager ?
• Nuget Packages Manager ?
• Build, Deploy …
11. Essayons ça! Un problème ?!
Mais il semble être indispensable d’utiliser un conteneur!
https://developer.xamarin.com/guides/xamarin-forms/controls/layouts/
12. Ça se fait en C# ?!
public class Interface2 : ContentPage
{
public Interface2()
{
EntryBien = new Entry
{
Placeholder = "Le bien à acheter",
};
EntryPrix = new Entry
{
Placeholder = "Prix",
};
var switcher = new Switch();
Content = new StackLayout
{
Children = {
new Label { Text = "Ajouter votre
nouvel achat!" },
EntryBien,
EntryPrix,
switcher }
};
}
Créons une deuxième interface ! (Add New Item Forms Page)
13. Mais le bouton ne fait RIEN pour le moment !
<Button Text="Click Me!"
Clicked="OnButtonClicked"/>
async void OnButtonClicked(object sender, EventArgs e)
{
await Navigation.PushModalAsync(new Interface2());
}
16. Enrichir notre Liste !
public class Produit
{
public String Price { get; set; }
public string Nom { get; set; }
}
public partial class MainPage : ContentPage
{
public ObservableCollection<Produit> productsList { get; set; }
public MainPage()
{
InitializeComponent();
productsList = new ObservableCollection<Produit>();
productsList.Add(new Produit() { Price = "20TND", Nom = "Viande" });
listView.ItemsSource = productsList;
}
17. Mais je veux ajouter moi même un produit !!
public MainPage(Produit p)
{
InitializeComponent();
productsList = new ObservableCollection<Produit>();
productsList.Add(new Produit() { Price = "20TND", Nom = "Viande" });
listView.ItemsSource = productsList;
if (p != null) { productsList.Add(p); }
}
ButtonValider.Clicked += ButtonValider_Clicked;
private async void ButtonValider_Clicked(object sender, EventArgs e)
{
Produit p = new Produit() { Nom = EntryBien.Text, Price = EntryPrix.Text };
MainPage main = new MainPage(p);
await Navigation.PushModalAsync(main);}