Xamarin.Forms 應用程式基本概念Xamarin.Forms Application Fundamentals

協助工具選項Accessibility

使用 Xamarin.Forms 納入無障礙功能 (例如支援螢幕閱讀工具) 的提示。Tips to incorporate accessible features (like supporting screen-reading tools) with Xamarin.Forms.

應用程式類別App Class

Application 類別是 Xamarin.Forms 的起始點:每個應用程式都必須實作子類別 App 來設定初始頁面。The Application class is the starting point for Xamarin.Forms – every app needs to implement a subclass App to set the initial page. 也會提供用於簡單資料儲存區的 Properties 集合。It also provides the Properties collection for simple data storage. 可以在 C# 或 XAML 中定義。It can be defined in either C# or XAML.

應用程式生命週期App Lifecycle

Application 類別 OnStartOnSleepOnResume 方法,以及強制回應導覽事件,可讓您以自訂程式碼處理應用程式生命週期事件。The Application class OnStart, OnSleep, and OnResume methods, as well as modal navigation events, let you handle application lifecycle events with custom code.

行為Behaviors

使用者介面控制項可以輕鬆擴充,而不需要使用行為來新增功能以進行子類別化。User interface controls can be easily extended without subclassing by using behaviors to add functionality.

自訂轉譯器Custom Renderers

自訂轉譯器可讓開發人員「覆寫」Xamarin.Forms 控制項的預設轉譯,以在每個平台上自訂其外觀和行為 (如需要,可使用原生 SDK)。Custom Renders let developers 'override' the default rendering of Xamarin.Forms controls to customize their appearance and behavior on each platform (using native SDKs if desired).

資料繫結Data Binding

資料繫結會連結兩個物件的屬性,以便在其中一個屬性變更時,自動反映在另一個屬性上。Data binding links the properties of two objects, allowing changes in one property to be automatically reflected in the other property. 資料繫結是 Model-View-ViewModel (MVVM) 應用程式架構不可或缺的一部分。Data binding is an integral part of the Model-View-ViewModel (MVVM) application architecture.

相依性服務Dependency Service

DependencyService 提供簡單的定位器,可讓您在共用程式碼中編寫介面,並提供會自動解析的平台特定實作,方便您在 Xamarin.Forms 中參考平台特定功能。The DependencyService provides a simple locator so that you can code to interfaces in your shared code and provide platform-specific implementations that are automatically resolved, making it easy to reference platform-specific functionality in Xamarin.Forms.

EffectsEffects

效果可讓您自訂每個平台上的原生控制項,通常用於小型的樣式變更。Effects allow the native controls on each platform to be customized, and are typically used for small styling changes.

檔案Files

透過 .NET Standard 程式庫的程式碼或使用內嵌資源,可以使用 Xamarin.Forms 處理檔案。File handling with Xamarin.Forms can be achieved using code in a .NET Standard library, or by using embedded resources.

GesturesGestures

Xamarin.Forms GestureRecognizer 類別支援使用者介面控制項上的點選、捏合以及平移手勢。The Xamarin.Forms GestureRecognizer class supports tap, pinch, and pan gestures on user interface controls.

當地語系化Localization

內建的 .NET 當地語系化架構,可用於透過 Xamarin.Forms 建置跨平台多語系應用程式。The built-in .NET localization framework can be used to build cross-platform multilingual applications with Xamarin.Forms.

本機資料庫Local Databases

Xamarin.Forms 使用 SQLite 資料庫引擎來支援資料庫驅動型應用程式,讓您可以將物件載入和儲存至共用程式碼。Xamarin.Forms supports database-driven applications using the SQLite database engine, which makes it possible to load and save objects in shared code.

訊息中心Messaging Center

除了簡單的訊息合約外,Xamarin.Forms MessagingCenter 可讓檢視模型和其他元件能夠在不需要知道彼此資訊的情況下進行通訊。Xamarin.Forms MessagingCenter enables view models and other components to communicate with without having to know anything about each other besides a simple Message contract.

Xamarin.Forms 會根據所使用的 Page 類型,提供多種不同的網頁導覽體驗。Xamarin.Forms provides a number of different page navigation experiences, depending upon the Page type being used.

ShellShell

Xamarin.Forms Shell 是應用程式的容器,可提供大部分應用程式需要的基本 UI 功能,讓您專注於應用程式的核心工作負載。Xamarin.Forms Shell is a container for applications, that provides fundamental UI features that most applications require, leaving you to focus on the application's core workload.

範本Templates

控制項範本可在執行階段輕鬆設定、重新設定佈景主題應用程式頁面,而資料範本可在受支援的控制項上定義資料呈現方式。Control templates provide the ability to easily theme and re-theme application pages at runtime, while data templates provide the ability to define the presentation of data on supported controls.

觸發程序Triggers

回應屬性變更及 XAML 中的事件以更新控制項。Update controls by responding to property changes and events in XAML.