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 的对象(如 Window.SystemBackdrop)的 SystemBackdrop 属性时。

重写此方法以创建和配置基础 ISystemBackdropController 及其 SystemBackdropConfiguration

适用于

另请参阅