官术网_书友最值得收藏!

Cross-platform development with Xamarin.Forms

The key ingredient in cross-platform development with Xamarin is code sharing. Sharing native code is great, but we still have the issue of writing separate user interface code for each platform. The Windows Presentation Framework (WPF) is a presentation system which uses an XML-based language known as Extensible Application Markup Language (XAML). Xamarin.Forms uses WPF and the Model-View-View-Model (MVVM) paradigm to build native user interfaces from a single C# shared code base, whilst maintaining access to all native APIs on each platform.

The preceding diagram represents a native architecture. We keep all the sharable code Inside the Shared C# App Logic block (normally a shared project) for each platform project to access, i.e. the GalleryItem class would be kept here since it is shared between both projects.

So how would this look in Xamarin.Forms?

Using Xamarin.Forms, since we have the ability to share the user interface screens, we can share the entire view and view model code between all platforms:

In the preceding diagram, the code contained in the Shared C# App Logic block is contained in a Portable Class Library (PCL), which each native project will import. Xamarin.Forms makes it possible to share up to 85% of code.

Let's now delve into development and setup our first Xamarin.Forms project.

主站蜘蛛池模板: 德庆县| 克拉玛依市| 巫山县| 桃江县| 农安县| 托里县| 耒阳市| 东平县| 鸡东县| 宁化县| 乐都县| 启东市| 垦利县| 九寨沟县| 青浦区| 隆子县| 丰县| 上栗县| 毕节市| 新建县| 雅江县| 微博| 开化县| 蕲春县| 丰都县| 南华县| 墨竹工卡县| 法库县| 辽源市| 岢岚县| 长丰县| 大同县| 永和县| 克东县| 晋宁县| 广宁县| 象山县| 扎鲁特旗| 酒泉市| 潍坊市| 富平县|