Download presentation
Presentation is loading. Please wait.
Published bySteven Ward Modified over 8 years ago
1
05 | Xamarin Forms, kódosztási technikák Farkas Bálint | Technical Evangelist | Microsoft
2
Xamarin.Forms bevezetés –Mi ez? –Követelmények Xamarin.Forms vezérlőelemek Kódosztási technikák –Portable Class Library-k –MVVM –Dependency Injection Heritage Properties Xamarin.Forms alapokon Xamarin.Forms Custom Renderer-ek Module Overview
3
Xamarin.Forms bevezetés
4
What is Xamarin.Forms?
6
Portable Class Library
7
Xamarin.Forms
8
Portable Class Library or Shared Project C# Platform Specific Shared C# Interface Code (Xamarin.Forms) Shared C# App Logic (ViewModels, Models etc)
9
Requires iOS 6.1+ Requires Android 4.0+ Requires WP8.0+ (Silverlight) WinRT previewben
10
Xamarin.Forms vezérlőelemek
11
Xamarin.Forms 1.Pages 2.Layouts 3.Views 4.Cells
12
Xamarin.Forms - Pages UIViewController Activity Page
13
Xamarin.Forms - Layouts
14
Xamarin.Forms - Views
15
Xamarin.Forms - Cells
16
Xamarin.Forms DataBinding Engine
17
DEMO Intro to Xamarin.Forms
18
Code Sharing – Portable Class Libraries
19
Portable Class Libraries Portable Class Library project template in Visual Studio 2012/2013 (except Express) –C# or Visual Basic –Good for creating a cross-platform.dll with pure business logic –Only managed code –Single codebase for Windows, Silverlight, Windows Phone, or Xbox –Only shared assemblies are available for use (mostly restricted to System namespaces) –Limited, but provides portable, modular, and encapsulated code
20
Portable Class Library One Source One Project One Binary Multiple Platforms
23
Portable Class Libraries Limits Platform Specific OS Functions Storage (no file I/O access) Alerts MessageBox GPS
24
Shared Projects #ifdef parancsokkal targetált kód Build időben hozzámásolódik a szülőprojekthez és azzal együtt fordul (ellentétben a PCL-lel, ami önálló DLL, így nem tudja, honnan van bereferálva)
25
Code Sharing – MVVM, Inversion of Control (IoC) and Dependency Injection
26
Container Dependency Injection Register Concrete Type PCL Locator Type1 : IType1 Type2 : IType2 Register ViewModel ViewModel IType2
27
Using Dependency Injection namespace HeritageProperties.PCL { public interface IGpsService { Task GetLocation(); }
28
public partial class LocationService : IGpsService { CLLocationManager manager = new CLLocationManager(); public Task GetLocation() { manager.StartUpdatingLocation(); return Task.Run(() => { var ret = new Location(); // code omitted for space // return the location return ret; }); }
29
SimpleIoc.Default.Register (); public MainViewModel(IGpsService gps) { this.GpsService = gps; }
30
ServiceLocator.Current.GetInstance ();
31
DEMO Implementing Heritage Properties for Android, iOS and Windows using Xamarin.Forms
32
Maps & Custom Renderers
33
// register the iGpsService for iOS SimpleIoc.Default.Register (); public MainViewModel(IGpsService gps, HeritagePropertyService service, INavigation navigation) { } Xamarin.Forms – Custom Renderers
34
[assembly: ExportRenderer(typeof(MapRenderer2), typeof(MapRenderer2Android))] public class MapRenderer2 : Map { } map = new MapRenderer2() { IsShowingUser = true, HeightRequest = 100, WidthRequest = 960, VerticalOptions = LayoutOptions.FillAndExpand }; Xamarin.Forms – Custom Renderers
35
Xamarin.Forms – Messaging Custom Renderer Custom Renderer (PCL) Send Message To Invoke Method Send Message To Notify of Event
36
DEMO Implementing Custom Renders For Maps
37
Xamarin.Forms intró –Mi ez? –Követelmények Xamarin.Forms vezérlőelemek Kódosztási technikák –Portable Class Library-k –MVVM –Dependency Injection Heritage Properties Xamarin.Forms alapokon Xamarin.Forms Custom Renderer-ek Module Recap
38
©2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.