語言

Element 類別

定義

提供所有 Xamarin 的基礎類別。形成階層元素。 此類別包含表示 Xamarin 元素所需的所有方法與屬性。形成階層。

public abstract class Element : Xamarin.Forms.BindableObject, Xamarin.Forms.IElementController, Xamarin.Forms.Internals.INameScope
type Element = class
    inherit BindableObject
    interface INameScope
    interface IElementController
繼承
System.Object
Element
衍生
實作

備註

下表說明視覺元素的重要類別:

ClassDescription
VisualElement Element A會佔據螢幕上的某個區域,具有視覺外觀,並能獲得觸控輸入。
Cell 儲存格都是要新增至 ListView 或 TableView 的項目。
Page VisualElement佔用大部分或全部螢幕且包含單一子系的 。
Layout Layout 具有 類型的 View單一子系,而的子類別 Layout<T> 具有多個子檢視的集合,包括其他版面配置。
控制與專用 View系統 圖的下方顯示的是Xamarin。表單類別用於通用可得的控制項,如 Buttons 和 TableViews。

建構函式

名稱 Description
Element()

受保護的建構子用於初始化元素。

欄位

名稱 Description
AutomationIdProperty

球場的背景倉庫 AutomationId 。

ClassIdProperty

識別 ClassId 可綁定屬性。

MenuProperty

附帶選單屬性的後備儲存庫。

屬性

名稱 Description
AutomationId

取得或設定值,允許自動化架構尋找此項目並與之互動。

BindingContext

取得或設定包含將被綁 BindableObject定屬性所針對的屬性的物件。

(繼承來源 BindableObject)
ClassId

取得或設定值,用來識別語意類似項目的集合。

Dispatcher

提供所有 Xamarin 的基礎類別。形成階層元素。 此類別包含表示 Xamarin 元素所需的所有方法與屬性。形成階層。

(繼承來源 BindableObject)
EffectControlProvider

供 Xamarin 內部使用。表單平台。

Effects

這是套用在這件物品上的效果清單。

Id

會獲得一個值,可以用來在應用程式執行過程中唯一識別元素。

LogicalChildren

供 Xamarin 內部使用。表單平台。

Parent

取得或設定該元素的父元素。

ParentView
已淘汰.

得到該元素的最近祖先元素。VisualElement

Platform
已淘汰.

提供所有 Xamarin 的基礎類別。形成階層元素。 此類別包含表示 Xamarin 元素所需的所有方法與屬性。形成階層。

RealParent

供 Xamarin 內部使用。表單平台。

StyleId

取得或設定使用者定義值來唯一識別項目。

方法

名稱 Description
ApplyBindings()

將綁定套用到 BindingContext。

(繼承來源 BindableObject)
ClearValue(BindableProperty)

清除由 設定SetValue的任意值。property

(繼承來源 BindableObject)
ClearValue(BindablePropertyKey)

清除由 所 SetValue 設定的屬性值,該 propertyKey屬性由 識別。

(繼承來源 BindableObject)
CoerceValue(BindableProperty)

提供所有 Xamarin 的基礎類別。形成階層元素。 此類別包含表示 Xamarin 元素所需的所有方法與屬性。形成階層。

(繼承來源 BindableObject)
CoerceValue(BindablePropertyKey)

提供所有 Xamarin 的基礎類別。形成階層元素。 此類別包含表示 Xamarin 元素所需的所有方法與屬性。形成階層。

(繼承來源 BindableObject)
Descendants()

供 Xamarin 內部使用。表單平台。

EffectIsAttached(String)

供 Xamarin 內部使用。表單平台。

FindByName(String)

傳回具有指定名稱的元素。

GetMenu(BindableObject)

得到 的bindable物件。Menu

GetValue(BindableProperty)

回傳 BindableProperty 所包含的值。

(繼承來源 BindableObject)
GetValues(BindableProperty, BindableProperty, BindableProperty)
已淘汰.

供 Xamarin 內部使用。表單平台。

(繼承來源 BindableObject)
GetValues(BindableProperty, BindableProperty)
已淘汰.

供 Xamarin 內部使用。表單平台。

(繼承來源 BindableObject)
IsSet(BindableProperty)

如果目標屬性存在且已設定,則回傳 true 。

(繼承來源 BindableObject)
OnBindingContextChanged()

只要項目的繫結內容變更時就叫用。 實作這個方法可為此事件加入類別處理。

OnChildAdded(Element)

每當需要發射事件 ChildAdded 時就會被召喚。 實作這個方法可為此事件加入類別處理。

OnChildRemoved(Element, Int32)

提供所有 Xamarin 的基礎類別。形成階層元素。 此類別包含表示 Xamarin 元素所需的所有方法與屬性。形成階層。

OnChildRemoved(Element)
已淘汰.

每當需要發射事件 ChildRemoved 時就會被召喚。 實作這個方法可為此事件加入類別處理。

OnParentSet()

每當元素的父節點被設定時會被調用。 實作這個方法,以便在項目新增至父系時新增行為。

OnPropertyChanged(String)

繫結屬性變更時呼叫的方法。

OnPropertyChanging(String)

從子類別呼叫此方法,通知某屬性即將發生變更。

(繼承來源 BindableObject)
RemoveBinding(BindableProperty)

移除先前設定的綁定。

(繼承來源 BindableObject)
RemoveDynamicResource(BindableProperty)

移除先前設定的動態資源

SetBinding(BindableProperty, BindingBase)

為屬性指派綁定。

(繼承來源 BindableObject)
SetDynamicResource(BindableProperty, String)

將此元素的 BindableProperty 屬性設定為透過 DynamicResource 更新並提供的鍵。

SetMenu(BindableObject, Menu)

設定 的 bindable選單。

SetValue(BindableProperty, Object)

設定指定屬性的值。

(繼承來源 BindableObject)
SetValue(BindablePropertyKey, Object)

設定 propertyKey 的值。

(繼承來源 BindableObject)
SetValueCore(BindableProperty, Object, SetValueFlags)

供 Xamarin 內部使用。表單平台。

(繼承來源 BindableObject)
SetValueFromRenderer(BindableProperty, Object)

供 Xamarin 內部使用。表單平台。

SetValueFromRenderer(BindablePropertyKey, Object)

供 Xamarin 內部使用。表單平台。

UnapplyBindings()

解除所有先前設定的綁定。

(繼承來源 BindableObject)

事件

名稱 Description
BindingContextChanged

每當 BindingContext 房產變更時,都會被提升。

(繼承來源 BindableObject)
ChildAdded

每當子元素加入元素時,就會發生。

ChildRemoved

每當子元素從元素中移除時,就會發生。

DescendantAdded

每當子元素加入元素子樹時,都會發生。

DescendantRemoved

每當子元素從元素子樹中移除時,就會發生。

PlatformSet
已淘汰.

提供所有 Xamarin 的基礎類別。形成階層元素。 此類別包含表示 Xamarin 元素所需的所有方法與屬性。形成階層。

PropertyChanged

當房產變更時會被提升。

(繼承來源 BindableObject)
PropertyChanging

當房產即將變更時,會被提升。

(繼承來源 BindableObject)

明確介面實作

名稱 Description
IDynamicResourceHandler.SetDynamicResource(BindableProperty, String)

供 Xamarin 內部使用。表單平台。

(繼承來源 BindableObject)
IElementController.SetValueFromRenderer(BindableProperty, Object)

供 Xamarin 內部使用。表單平台。

INameScope.RegisterName(String, Object)

僅限內部使用。

擴充方法

名稱 Description
FindByName<T>(Element, String)

回傳包含 的範圍內element名稱為 name 的型別T實例。

GetPropertyIfSet<T>(BindableObject, BindableProperty, T)

提供所有 Xamarin 的基礎類別。形成階層元素。 此類別包含表示 Xamarin 元素所需的所有方法與屬性。形成階層。

SetAppThemeColor(BindableObject, BindableProperty, Color, Color)

提供所有 Xamarin 的基礎類別。形成階層元素。 此類別包含表示 Xamarin 元素所需的所有方法與屬性。形成階層。

SetBinding(BindableObject, BindableProperty, String, BindingMode, IValueConverter, String)

建立並將繫結套用至屬性。

SetBinding<TSource>(BindableObject, BindableProperty, Expression<Func<TSource,Object>>, BindingMode, IValueConverter, String)
已淘汰.

從表達式中建立並套用綁定。

SetOnAppTheme<T>(BindableObject, BindableProperty, T, T)

提供所有 Xamarin 的基礎類別。形成階層元素。 此類別包含表示 Xamarin 元素所需的所有方法與屬性。形成階層。

適用於