Xamarin.Forms Hands On.

Slides:



Advertisements
Similar presentations
Android UserInterfaces Nasrullah Niazi. overView All user interface elements in an Android app are built using View and ViewGroup objects. A View is an.
Advertisements

 2007 Dr. Natheer Khasawneh. Chapter 13. Graphical User Interface Concepts: Part 1.
Dinko Jakovljević Microsoft Student Partner | BambooLab
Alejandro Campos Magencio MS Technical Extreme Code Sharing with C# Y A XB.
Charles Petzold Navigation.
Mobile Development with Xamarin Mark Allan Ranyart
Introducing Xamarin 2.0 Introducing Xamarin 2.0 Michael Hutchinson
Xamarin.Forms. Xamarin.Forms v. Standard Xamarin Architecture iOS C# UI Android C# UI Windows C# UI Shared App Logic Xamarin.Forms Standard Xamarin.Forms.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 9: Customize! Navigating with a Master/Detail.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Developing Mobile Applications using MVVM with Xamarin Forms
CS378 - Mobile Computing Web - WebView and Web Services.
© 2007 IBM Corporation IBM Global Engineering Solutions IBM Blue Gene/P Blue Gene/P Navigator.
AJAX in ASP.NET James Crowley Developer Fusion
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Overview of UI Development for Windows Store Apps
1 Intro XAML Attribute syntax & property syntax Panels Reusable resources Controls Data binding Steen Jensen, spring 2014.
Developing Enterprise Mobile Apps with Xamarin Loren Horsager CEO, Mobile Composer.
Windows News app uses Notification Hubs Platform Notification Service App back-end Client app.
V 1.0 Programming III. Automatic notifications (…Changed, INofityPropertyChanged, ObservableCollection ) Data formatters Data conversions Resources.
Web hosting in app Creating a Windows Store app with web assets.
The Windows Runtime (WinRT) is the shared runtime and API space used by store apps across the Windows platform (phone and client) 5 Common WinRT.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Unit 3: Adding Code to a Microsoft ASP.NET Web Form.
Understanding Xamarin Development Matt
Xamarin iOS Hands On. Hands-On: Xamarin iOS Ziele – Kennenlernen von Xamarin Android – Native UI –
Microsoft UI Stack Ronnie Saurenmann Technical Evangelist, Microsoft Switzerland
Developing AJAX Web applications with Castle Monorail David De Florinier Gojko Adzic Skills Matter 12/06/08.
Svetlin Nakov Telerik Corporation
Module 7 Data Binding to Collections. Module Overview Binding to Collections of Objects Using Collection Views Create Master-Detail User Interfaces Using.
Windows Presentation Foundation (WPF). Introduction Separates appearance of user interface from behavior Appearance usually specified by XAML Behavior.
Windows 10 UWP MVVM In Depth
Microsoft ® Official Course Developing a Publishing Site for Web Content Microsoft SharePoint 2013 SharePoint Practice.
04 |Sharing Code Between Windows 8 and Windows Phone 8 in Visual Studio Ben Riga
V 1.0 Programming III. Automatic notifications with data binding (…Changed, INofityPropertyChanged, ObservableCollection, DataTemplate) Data formatters.
User Interface Layout Interaction. EventsEvent Handlers/Listeners Interacting with a user.
V 1.0 Programming III. Visual/FrameworkElement descendants.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
05 | Xamarin Forms, kódosztási technikák Farkas Bálint | Technical Evangelist | Microsoft.
/DEV/TM #1 Building Cross-Platform Apps with Xamarin and MvvmCross Flavius-Radu DEMIAN.
Xamarin Android Hands On. Hands-On: Xamarin Android Ziele – Kennenlernen von Xamarin Android – Native UI –
WebViews UIWebView. Controller Architecture UITabBarController Controls the first view that the user sees The view controller class (and xib) that manages.
16 Copyright © 2004, Oracle. All rights reserved. Building ADF UIX View Components.
Build Fast and Beautiful Apps with Xamarin.Forms
What’s New In Xamarin.Forms
Xamarin Development with
Cross-platform app development
In Windows 8 Store Applications
Microsoft /26/ :19 PM BRK3114 Create cross-platform mobile apps with Xamarin that connect to Office Services (BRK3114) Fabian G. Williams Sr.
State of the Art in Mobile Development - AndRES Käver, 2016
Beginning of Xamarin for iOS development
Xamarin Studio Xamarin Curriculum for Xamarin Studio
Uvod u Xamarin.Forms Almir Vuk App Impact 4/20/2018 3:04 AM
Basic Controls and Plugins
Microsoft Build /23/ :01 AM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY,
Rapid Mobile App Development with Xamarin.Forms
Build data-driven collection and list apps using XAML
Introduction to the Visual C# 2005 Express Edition IDE
Xamarin Technology By: Ammar Salman Instructor: Dr. Jim Fawcett
Lecture 3 Multiple Pages.
Customizing your device experience with assigned access
Microsoft Connect /19/2018 7:55 PM
Xamarin Forms Lecture 2 Greetings Demos.
Tips and tricks for developing Metro style apps using XAML
Lists and List Items in Windows Runtime Apps
Android Topics Threads and the MessageQueue
4/9/ | Contracts © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
A very brief introduction
ASP.NET 2.0 Overview Created By: Ajay Bahoriya.
Displaying Local Images
Bringing existing managed code into Metro style apps
Presentation transcript:

Xamarin.Forms Hands On

Hands-On: Xamarin Forms Ziele Kennenlernen von Xamarin.Forms, wichtigste Layouts und Views UI aus Code mit Data Binding Erweitern von Forms Elementen mit Native Custom Renderer UI aus Xaml, Custom View mit XAML Aufrufen von Systemfunktionen mit DependencyService

Pages http://developer.xamarin.com/guides/cross-platform/xamarin-forms/controls/pages/

Layouts http://developer.xamarin.com/guides/cross-platform/xamarin-forms/controls/layouts/

LayoutOptions Start Center End Expand WidthRequest HeightRequest

Views http://developer.xamarin.com/guides/cross-platform/xamarin-forms/controls/views/

UI Gallery Sample App Zeigt Verwendung wichtigster Elemente

App Lifecycle http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/app-lifecycle/

Demo App New Solution Blank Xamarin Forms App PCL Name, id etc. Project Structure Run on iOS & Android

Demo App Step 1 New Solution Blank Xamarin Forms App PCL Name, id etc. Run on iOS & Android

Demo App Step 2 Master Detail Page public class MasterDetail : MasterDetailPage Master: ListView Detail: ContentView Model: Shop ImageSource Image String Name String Description String URL

Data Binding / Cell Template var shops = new List<Shop>{ new Shop{Image=“http://”, Name=“”…} … } var list = new ListView { ItemsSource = shops, ItemTemplate = new DataTemplate (() => { var imageCell = new ImageCell (); imageCell.SetBinding (ImageCell.ImageSourceProperty, "Image"); imageCell.SetBinding (ImageCell.TextProperty, "Name"); imageCell.SetBinding (ImageCell.DetailProperty, "Description"); return imageCell; }) };

Select item / set detail binding context list.ItemSelected += (sender, e) => { Detail.BindingContext = e.SelectedItem; IsPresented = false; }; list.SelectedItem = shops [0];

Detail Page Data binding public class ShopPage : ContentPage{ this.SetBinding (ContentPage.TitleProperty, "Name"); var shopLabel = new Label { XAlign = TextAlignment.Center }; Content = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { shopLabel } }; shopLabel.SetBinding (Label.TextProperty, "Name"); }

Detail Page: Browser View var browser = new WebView{  VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; browser.SetBinding (WebView.SourceProperty, "URL"); Navigate Back / Forward: Add Button (-> Horizontal StackLayout)

Problem: Reload missing GoForward GoBack Eval(string) Reload? (Native Function)

Solution: Custom WebView, Renderer Create Class MyWebView : WebView public delegate void ReloadDelegate(); public ReloadDelegate Reload;

Android Renderer public class MyWebViewRenderer : WebViewRenderer { protected override void OnElementChanged (ElementChangedEventArgs<WebView> e)         {             base.OnElementChanged (e);             if (e.OldElement != null) {                 ((MyWebView)e.OldElement).Reload -= DoReload;             }             ((MyWebView)e.NewElement).Reload += DoReload;         }         void DoReload(){             Control.Reload ();         } }

iOS Renderer public class MyWebViewRenderer : WebViewRenderer     { protected override void OnElementChanged (VisualElementChangedEventArgs e)         {             base.OnElementChanged (e);             if (e.OldElement != null) {                 ((MyWebView)e.OldElement).Reload -= DoReload;             }             ((MyWebView)e.NewElement).Reload += DoReload;         }         void DoReload(){             Reload ();         }     }

Magic using xyz; [assembly: ExportRenderer ( typeof (MyWebView), typeof (MyWebViewRenderer))] Namespace xyz{ public class MyWebViewRenderer… }

XAML View Create new Xaml View (ShopPage2) <?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="Shops.ShopPage2”>     <ContentPage.Content> ….     </ContentPage.Content> </ContentPage>

Xaml Content <StackLayout HorizontalOptions="FillAndExpand"  VerticalOptions="FillAndExpand">             <WebView x:Name="browser”  Source="{Binding URL}"  HorizontalOptions="FillAndExpand"  VerticalOptions="FillAndExpand"/>             <StackLayout Orientation="Horizontal">                 <Button Text="Back" Clicked="BackClicked"/>                 <Button Text="Reload" Clicked="ReloadClicked"/>             </StackLayout>         </StackLayout>

CodeBehind Class public partial class ShopPage2 : ContentPage     {         public ShopPage2 ()         {             InitializeComponent ();         }         void BackClicked(object sender, EventArgs e){             browser.GoBack ();         }         void ReloadClicked(object sender, EventArgs e){             browser.Reload ();         }     }

Beispiel App Master-Detail auf iPad Quer

DependencyService Access Native functionality from shared code Declare Interface: public interface IToastService { void ShowToast(string text); }

Implementation Android public class ToastService : IToastService     {         public ToastService ()         {         }         public void ShowToast(string text){             var ctx = Forms.Context;             Toast toast =  Toast.MakeText(Forms.Context, text, ToastLength.Long);             toast.Show();         }     }

Implementation iOS public async void ShowToast(string text){             var alert = new UIAlertView(text, null, null, null, null);             alert.Show ();             await Task.Delay(3000);             alert.DismissWithClickedButtonIndex (-1, true); }

Magic Using xyz; [assembly: Xamarin.Forms.Dependency (typeof (ToastService))] Namespace xyz{ class …. }

Usage var service = DependencyService.Get<IToastService> (); service .ShowToast("Hallo Workshop"); Attention: only one instance!

Platform Tweaks http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/platform-specifics/