Share via


SystemBackdrop 類別

定義

用來轉譯Mica和壓克力等材質的自定義系統基類。

public ref class SystemBackdrop : DependencyObject
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.WinUIContract, 262144)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class SystemBackdrop : DependencyObject
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.WinUIContract), 262144)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public class SystemBackdrop : DependencyObject
Public Class SystemBackdrop
Inherits DependencyObject
繼承
Object Platform::Object IInspectable DependencyObject SystemBackdrop
衍生
屬性

範例

此範例示範使用 MicaController實作的自定義系統基底類別。

呼叫base OnTargetConnected 方法會初始化 GetDefaultSystemBackdropConfiguration 傳回的預設組態物件,以反映影響此 SystemBackdrop 實例的環境變更,) 所 connectedTarget, XamlRoot 指定的 (。

雖然此頁面上的範例不支援共用 MicaSystemBackdrop 實例 (例如, Window1.SystemBackdrop = Window2.SystemBackdrop = myMicaSystemBackdrop) ,但內建 MicaBackdropDesktopAcrylicBackdrop 材質可支援這類共用。 若要在自定義材質中實作共用,請向量化支援 ISystemBackdropController 記憶體,以針對每個使用 (內容保留個別的實例,例如,透過) 上的 connectedTarget 地圖索引鍵。 請注意,同樣地,SystemBackdrop會將 GetDefaultSystemBackdropConfiguration 傳回的相關聯預設組態物件向量化,確保設定會在共享時SystemBackdrop反映每個使用內容。

<Window
    ... >
    <Window.SystemBackdrop>
        <local:MicaSystemBackdrop/>
    </Window.SystemBackdrop>

    <!-- XAML content -->

</Window>
public class MicaSystemBackdrop : SystemBackdrop
{
    MicaController micaController;

    protected override void OnTargetConnected(ICompositionSupportsSystemBackdrop connectedTarget, XamlRoot xamlRoot)
    {
        // Call the base method to initialize the default configuration object.
        base.OnTargetConnected(connectedTarget, xamlRoot);

        // This example does not support sharing MicaSystemBackdrop instances.
        if (micaController is not null)
        {
            throw new Exception("This controller cannot be shared");
        }

        micaController = new MicaController();
        // Set configuration.
        SystemBackdropConfiguration defaultConfig = GetDefaultSystemBackdropConfiguration(connectedTarget, xamlRoot);
        micaController.SetSystemBackdropConfiguration(defaultConfig);
        // Add target.
        micaController.AddSystemBackdropTarget(connectedTarget);
    }

    protected override void OnTargetDisconnected(ICompositionSupportsSystemBackdrop disconnectedTarget)
    {
        base.OnTargetDisconnected(disconnectedTarget);

        micaController.RemoveSystemBackdropTarget(disconnectedTarget);
        micaController = null;
    }
}

備註

使用此類別來建立自定義系統基底。 您不會直接建立此類別, (記下受保護的建構函式) 。 而是將它子類別化,以新增您的自定義支援。 您也可以使用其中一個內建衍生類別 MicaBackdropDesktopAcrylicBackdrop

一般而言,自定義材質會覆寫 OnTargetConnected 來建立及設定支援 ISystemBackdropController,這會管理用來填滿底板區域的 CompositionBrush 。 筆刷的最終圖元轉譯會受到下列影響:

內建控制器 (MicaControllerDesktopAcrylicController) 支援下列參數來自定義其外觀: FallbackColorLuminosityOpacityTintColorTintOpacity。 內建系統 (MicaBackdropDesktopAcrylicBackdrop) 不會公開 FallbackColor 或材料自定義屬性 (TintOpacity等) 。 相反地,它們依賴基礎 MicaControllerDesktopAcrylicController的默認淺色/深色組態。 若要自定義這些屬性,請建立衍生自 SystemBackdrop 的自定義材質類別,並公開所需的屬性。

建構函式

SystemBackdrop()

初始化 SystemBackdrop 類別的新執行個體。

屬性

Dispatcher

一律會在 Windows 應用程式 SDK 應用程式中傳回null。 請改用 DispatcherQueue

(繼承來源 DependencyObject)
DispatcherQueue

DispatcherQueue取得與這個 物件相關聯的 。 DispatcherQueue表示即使程式代碼是由非 UI 線程起始,也可以存取 DependencyObject UI 線程上的 。

(繼承來源 DependencyObject)

方法

ClearValue(DependencyProperty)

清除相依性屬性的本機值。

(繼承來源 DependencyObject)
GetAnimationBaseValue(DependencyProperty)

傳回針對相依性屬性所建立的任何基底值,如果動畫未使用中,則會套用。

(繼承來源 DependencyObject)
GetDefaultSystemBackdropConfiguration(ICompositionSupportsSystemBackdrop, XamlRoot)

擷取可傳遞至ISystemBackdropControllerWithTargets.SetSystemBackdropConfiguration的默認SystemBackdropConfiguration物件。

GetValue(DependencyProperty)

DependencyObject 傳回相依性屬性的目前有效值。

(繼承來源 DependencyObject)
OnDefaultSystemBackdropConfigurationChanged(ICompositionSupportsSystemBackdrop, XamlRoot)

覆寫這個方法,以在變更傳 GetDefaultSystemBackdropConfiguration 回的物件時呼叫。 如果您使用自定義 SystemBackdropConfiguration,這會很有用。

OnTargetConnected(ICompositionSupportsSystemBackdrop, XamlRoot)

當這個物件附加至有效的容器時呼叫;例如,在上 Window.SystemBackdrop設定時。

OnTargetDisconnected(ICompositionSupportsSystemBackdrop)

從容器清除此物件時呼叫。

ReadLocalValue(DependencyProperty)

如果已設定本機值,則傳回相依性屬性的本機值。

(繼承來源 DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback)

註冊通知函式,以接聽此 DependencyObject 實例上特定 DependencyProperty 的變更。

(繼承來源 DependencyObject)
SetValue(DependencyProperty, Object)

DependencyObject 上設定相依性屬性的本機值。

(繼承來源 DependencyObject)
UnregisterPropertyChangedCallback(DependencyProperty, Int64)

取消先前透過呼叫 RegisterPropertyChangedCallback 註冊的變更通知。

(繼承來源 DependencyObject)

適用於

另請參閱