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

  • Xamarin Blueprints
  • Michael Williams
  • 215字
  • 2021-07-08 11:48:21

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.

主站蜘蛛池模板: 玛多县| 靖边县| 无棣县| 托克逊县| 平原县| 丰城市| 新宁县| 合山市| 盱眙县| 东丰县| 兰溪市| 磴口县| 湾仔区| 大姚县| 海口市| 孟津县| 鄂托克旗| 宁武县| 潜山县| 雅江县| 蛟河市| 墨竹工卡县| 株洲县| 营口市| 周口市| 水城县| 江山市| 安宁市| 长丰县| 南宁市| 南皮县| 永城市| 亳州市| 奉新县| 巨野县| 年辖:市辖区| 长宁区| 三门峡市| 合江县| 宜章县| 大竹县|