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

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.

主站蜘蛛池模板: 富蕴县| 芮城县| 平乡县| 大庆市| 喀喇| 正定县| 普兰店市| 呈贡县| 汾西县| 雷州市| 阿勒泰市| 广昌县| 江油市| 哈密市| 广西| 盐山县| 长子县| 定结县| 安塞县| 威远县| 蒙山县| 金坛市| 莆田市| 集贤县| 城口县| 孝感市| 霍山县| 调兵山市| 宝坻区| 长阳| 江城| 巴楚县| 湄潭县| 三门峡市| 天门市| 新宾| 微博| 平果县| 孟连| 枝江市| 盐池县|