共用方式為


SystemBackdrop.OnTargetConnected 方法

定義

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

protected:
 virtual void OnTargetConnected(ICompositionSupportsSystemBackdrop ^ connectedTarget, XamlRoot ^ xamlRoot) = OnTargetConnected;
void OnTargetConnected(ICompositionSupportsSystemBackdrop const& connectedTarget, XamlRoot const& xamlRoot);
protected virtual void OnTargetConnected(ICompositionSupportsSystemBackdrop connectedTarget, XamlRoot xamlRoot);
function onTargetConnected(connectedTarget, xamlRoot)
Protected Overridable Sub OnTargetConnected (connectedTarget As ICompositionSupportsSystemBackdrop, xamlRoot As XamlRoot)

參數

connectedTarget
ICompositionSupportsSystemBackdrop

底下的目標。

xamlRoot
XamlRoot

底下目標的 XAML 根目錄。

範例

如需完整範例,請參閱 SystemBackdrop

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);
}

備註

當這個 SystemBackdrop 附加至有效的容器時,會呼叫這個方法;也就是說,當它指派給實作 ICompositionSupportsSystemBackdrop 的物件 SystemBackdrop 屬性時,例如 Window.SystemBackdrop

覆寫此方法以建立和設定基礎 ISystemBackdropController 及其 SystemBackdropConfiguration

適用於

另請參閱