Share via


Application 類別

定義

代表跨平台行動應用程式的類別。

public ref class Application : Microsoft::Maui::Controls::Element, Microsoft::Maui::Controls::IApplicationController, Microsoft::Maui::Controls::IElementConfiguration<Microsoft::Maui::Controls::Application ^>, Microsoft::Maui::IApplication, Microsoft::Maui::IVisualTreeElement
public class Application : Microsoft.Maui.Controls.Element, Microsoft.Maui.Controls.IApplicationController, Microsoft.Maui.Controls.IElementConfiguration<Microsoft.Maui.Controls.Application>, Microsoft.Maui.IApplication, Microsoft.Maui.IVisualTreeElement
type Application = class
    inherit Element
    interface IApplicationController
    interface IElementConfiguration<Application>
    interface IVisualTreeElement
    interface IApplication
    interface IElement
Public Class Application
Inherits Element
Implements IApplication, IApplicationController, IElementConfiguration(Of Application), IVisualTreeElement
繼承
實作

備註

類別 Application 是 Microsoft.Maui.Controls 應用程式的核心。 它會設定應用程式的根頁面、在字典中 Properties 應用程式調用之間保存基本類型數據,並提供事件來回應強制回應強制回應模式檢視的推送和快顯。 Visual Studio 會在新的 Microsoft.Maui.Controls 解決方案的適當專案中為開發人員建立此類別。

Visual Studio for Mac 和Visual Studio會在開發人員建立新的 Microsoft.Maui.Controls 解決方案時,為應用程式建立 XAML 和程式代碼後置檔案。 下列範例示範一般 Application 類別,其資源字典中有專案。

<Application xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="App1.App">
<Application.Resources>
<Color x:Key="ButtonBackgroundColor">Red</Color>
</Application.Resources>
</Application>
public partial class App : Application
{
    public App()
    {
        InitializeComponent();

        MainPage = new MainPage();
    }

    protected override void OnStart()
    {
        // Handle when your app starts
    }

    protected override void OnSleep()
    {
        // Handle when your app sleeps
    }

    protected override void OnResume()
    {
        // Handle when your app resumes
    }
}

建構函式

Application()

初始化新的 Application 執行個體。

欄位

ControlsApplicationMapper
已淘汰.

代表跨平台行動應用程式的類別。

屬性

AccentColor

代表跨平台行動應用程式的類別。

AppLinks

取得開發人員用來註冊或取消註冊應用程式連結的物件。

AutomationId

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

(繼承來源 Element)
BindingContext

取得或設定 對象,這個物件包含系結屬性所屬之系結屬性的目標屬性 BindableObject。 這是可繫結屬性。

(繼承來源 BindableObject)
ClassId

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

(繼承來源 Element)
Current

取得目前的應用程式。

Dispatcher

取得建立這個可系結物件時可用的發送器,否則會嘗試尋找最接近的可用發送器, (可能是視窗/應用程式的) 。

(繼承來源 BindableObject)
EffectControlProvider

供 .NET MAUI 內部使用。

(繼承來源 Element)
Effects

取得或設定將在運行時間套用至 元素的樣式和屬性。

(繼承來源 Element)
Handler

取得或設定這個項目的相關聯處理程式。

(繼承來源 Element)
Id

取得值,這個值可用來在應用程式執行期間唯一識別專案。

(繼承來源 Element)
LogicalChildren
已淘汰.

供 Microsoft.Maui.Controls 平台內部使用。

(繼承來源 Element)
MainPage

取得或設定應用程式的根頁面。

NavigationProxy

供 Microsoft.Maui.Controls 平台內部使用。

Parent

取得或設定這個專案的父代 Element

(繼承來源 Element)
PlatformAppTheme

代表跨平台行動應用程式的類別。

Properties
已淘汰.

取得此 Application 物件的持續性屬性字典。

RealParent

供 .NET MAUI 內部使用。

(繼承來源 Element)
RequestedTheme

代表跨平台行動應用程式的類別。

Resources

取得或設定此 Application 物件的資源字典。

StyleId

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

(繼承來源 Element)
UserAppTheme

代表跨平台行動應用程式的類別。

Windows

代表跨平台行動應用程式的類別。

方法

AddLogicalChild(Element)

Element將加入邏輯子系。

(繼承來源 Element)
ApplyBindings()

將所有目前的系結套用至 BindingContext

(繼承來源 BindableObject)
CleanUp()

代表跨平台行動應用程式的類別。

ClearLogicalChildren()

拿掉所有子系 Element

(繼承來源 Element)
ClearValue(BindableProperty)

清除先前為可系結屬性設定的任何值。

(繼承來源 BindableObject)
ClearValue(BindablePropertyKey)

清除先前針對可系結屬性設定的任何值,其索引鍵所識別。

(繼承來源 BindableObject)
CloseWindow(Window)

代表跨平台行動應用程式的類別。

CoerceValue(BindableProperty)

強制指定可系結屬性的值。 這是藉由叫 BindableProperty.CoerceValueDelegate 用指定的可系結屬性來完成。

(繼承來源 BindableObject)
CoerceValue(BindablePropertyKey)

強制指定可系結屬性的值。 這是藉由叫 BindableProperty.CoerceValueDelegate 用指定的可系結屬性來完成。

(繼承來源 BindableObject)
CreateWindow(IActivationState)

代表跨平台行動應用程式的類別。

EffectIsAttached(String)

供 .NET MAUI 內部使用。

(繼承來源 Element)
FindByName(String)

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

(繼承來源 Element)
GetValue(BindableProperty)

傳回包含在指定可系結屬性中的值。

(繼承來源 BindableObject)
InsertLogicalChild(Int32, Element)

Element將 插入至指定索引處的邏輯子系。

(繼承來源 Element)
IsSet(BindableProperty)

判斷可系結屬性是否存在且已設定值。

(繼承來源 BindableObject)
On<T>()

傳回此 TElement 的平台特定執行個體,可在其上呼叫平台特定方法。

OnAppLinkRequestReceived(Uri)

代表跨平台行動應用程式的類別。

OnBindingContextChanged()

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

(繼承來源 Element)
OnChildAdded(Element)

引發 ChildAdded 事件。 實作這個方法可為此事件加入類別處理。

(繼承來源 Element)
OnChildRemoved(Element, Int32)

引發 ChildRemoved 事件。 實作這個方法以新增此事件的類別處理

(繼承來源 Element)
OnHandlerChanged()

在衍生類別中覆寫時,應該引發 HandlerChanged 事件。

(繼承來源 Element)
OnHandlerChanging(HandlerChangingEventArgs)

在衍生類別中覆寫時,應該引發 HandlerChanging 事件。

(繼承來源 Element)
OnParentChanged()

在衍生類別中覆寫時,應該引發 ParentChanged 事件。

(繼承來源 Element)
OnParentChanging(ParentChangingEventArgs)

在衍生類別中覆寫時,應該引發 ParentChanging 事件。

(繼承來源 Element)
OnParentSet()

代表跨平台行動應用程式的類別。

OnPropertyChanged(String)

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

(繼承來源 Element)
OnPropertyChanging(String)

引發 PropertyChanging 事件。

(繼承來源 BindableObject)
OnResume()

代表跨平台行動應用程式的類別。

OnSleep()

代表跨平台行動應用程式的類別。

OnStart()

代表跨平台行動應用程式的類別。

OpenWindow(Window)

代表跨平台行動應用程式的類別。

Quit()

結束應用程式。

RemoveBinding(BindableProperty)

從可系結的屬性中移除先前設定的系結。

(繼承來源 BindableObject)
RemoveDynamicResource(BindableProperty)

拿掉先前設定的動態資源。

(繼承來源 Element)
RemoveLogicalChild(Element)

從邏輯子系中移除第一個出現的特定 Element 專案。

(繼承來源 Element)
SavePropertiesAsync()
已淘汰.

以非同步方式保存應用程式物件的 Properties 字典。

SendOnAppLinkRequestReceived(Uri)

供 Microsoft.Maui.Controls 平台內部使用。

SetAppIndexingProvider(IAppIndexingProvider)

供 Microsoft.Maui.Controls 平台內部使用。

SetBinding(BindableProperty, BindingBase)

將系結指派給可系結的屬性。

(繼承來源 BindableObject)
SetCurrentApplication(Application)

供 Microsoft.Maui.Controls 平台內部使用。

SetDynamicResource(BindableProperty, String)

BindableProperty使用提供的索引鍵,設定要透過 DynamicResource 更新這個項目的 屬性。

(繼承來源 Element)
SetValue(BindableProperty, Object)

設定指定之可系結屬性的值。

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

設定指定之可系結屬性的值。

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

供 Microsoft.Maui.Controls 平台內部使用。

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

供 .NET MAUI 內部使用。

(繼承來源 Element)
SetValueFromRenderer(BindablePropertyKey, Object)

供 .NET MAUI 內部使用。

(繼承來源 Element)
UnapplyBindings()

從目前內容中移除所有目前的系結。

(繼承來源 BindableObject)

事件

BindingContextChanged

發生於 BindingContext 屬性的值變更時。

(繼承來源 BindableObject)
ChildAdded

每當子專案加入至 元素時引發。

(繼承來源 Element)
ChildRemoved

每當從專案中移除子項目時引發。

(繼承來源 Element)
DescendantAdded

每當子專案加入至專案的子樹時引發。

(繼承來源 Element)
DescendantRemoved

每當從專案子樹中移除子項目時引發。

(繼承來源 Element)
HandlerChanged

每當項目的處理程式變更時引發。

(繼承來源 Element)
HandlerChanging

每當項目的處理程序開始變更時引發。

(繼承來源 Element)
ModalPopped

代表跨平台行動應用程式的類別。

ModalPopping

代表跨平台行動應用程式的類別。

ModalPushed

代表跨平台行動應用程式的類別。

ModalPushing

代表跨平台行動應用程式的類別。

PageAppearing

代表跨平台行動應用程式的類別。

PageDisappearing

代表跨平台行動應用程式的類別。

ParentChanged

每當專案的父代變更時引發。

(繼承來源 Element)
ParentChanging

每當項目的 開始變更時引發。

(繼承來源 Element)
PropertyChanged

當屬性值變更時發生。

(繼承來源 BindableObject)
PropertyChanging

當屬性值變更中時發生。

(繼承來源 BindableObject)
RequestedThemeChanged

代表跨平台行動應用程式的類別。

明確介面實作

IApplication.CloseWindow(IWindow)

代表跨平台行動應用程式的類別。

IApplication.CreateWindow(IActivationState)

代表跨平台行動應用程式的類別。

IApplication.OpenWindow(IWindow)

代表跨平台行動應用程式的類別。

IApplication.ThemeChanged()

代表跨平台行動應用程式的類別。

IApplication.Windows

代表跨平台行動應用程式的類別。

IContextFlyoutElement.ContextFlyout

ContextFlyout取得檢視的 。 功能表飛出視窗、功能表飛出視窗子專案和功能表飛出視窗分隔符可以新增至內容飛出視窗。

(繼承來源 Element)
IDynamicResourceHandler.SetDynamicResource(BindableProperty, String)

代表跨平台行動應用程式的類別。

(繼承來源 BindableObject)
IEffectControlProvider.RegisterEffect(Effect)

代表跨平台行動應用程式的類別。

(繼承來源 Element)
IElement.Parent

取得專案的父代。

(繼承來源 Element)
IElementController.Descendants()

供 .NET MAUI 內部使用。

(繼承來源 Element)
IElementController.LogicalChildren

供 .NET MAUI 內部使用。

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

供 .NET MAUI 內部使用。

(繼承來源 Element)
INameScope.RegisterName(String, Object)

供 .NET MAUI 內部使用。

(繼承來源 Element)
INameScope.UnregisterName(String)

供 .NET MAUI 內部使用。

(繼承來源 Element)
IToolTipElement.ToolTip

代表小型矩形彈出視窗,當使用者將指標放在檢視上時,會顯示檢視用途的簡短描述。

(繼承來源 Element)
IVisualTreeElement.GetVisualChildren()

代表跨平台行動應用程式的類別。

IVisualTreeElement.GetVisualParent()

取得項目的視覺父代。

(繼承來源 Element)

擴充方法

GetPropertyIfSet<T>(BindableObject, BindableProperty, T)

代表跨平台行動應用程式的類別。

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

代表跨平台行動應用程式的類別。

SetAppThemeColor(BindableObject, BindableProperty, Color, Color)

代表跨平台行動應用程式的類別。

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

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

FindByName<T>(Element, String)

代表跨平台行動應用程式的類別。

ToHandler(IElement, IMauiContext)

代表跨平台行動應用程式的類別。

ToPlatform(IElement, IMauiContext)

代表跨平台行動應用程式的類別。

GetVisualElementWindow(IVisualTreeElement)

如果元素包含在其中,則取得包含可視化樹狀結構項目的視窗。

GetVisualTreeDescendants(IVisualTreeElement)

取得子系的整個階層,做為指定可視化樹狀結構元素的子系列表。

GetVisualTreeElements(IVisualTreeElement, Point)

根據指定的Point,取得可視化樹狀結構專案的子系列表。

GetVisualTreeElements(IVisualTreeElement, Rect)

根據矩形取得可視化樹狀結構元素子系的清單。

GetVisualTreeElements(IVisualTreeElement, Double, Double)

根據指定的 x、y 點,取得可視化樹狀結構元素子系的清單。

GetVisualTreeElements(IVisualTreeElement, Double, Double, Double, Double)

根據其座標所定義的矩形,取得可視化樹狀結構元素子系的清單,該矩形是以平台單位指定,而不是圖元。

適用於