Skip to content

Latest commit

 

History

History
59 lines (40 loc) · 2.4 KB

systembackdrop_ontargetconnected_1517461312.md

File metadata and controls

59 lines (40 loc) · 2.4 KB
-api-id -api-type
M:Microsoft.UI.Xaml.Media.SystemBackdrop.OnTargetConnected(Microsoft.UI.Composition.ICompositionSupportsSystemBackdrop,Microsoft.UI.Xaml.XamlRoot)
winrt method

Microsoft.UI.Xaml.Media.SystemBackdrop.OnTargetConnected(Microsoft.UI.Composition.ICompositionSupportsSystemBackdrop,Microsoft.UI.Xaml.XamlRoot)

-description

Called when this object is attached to a valid container; for example, when set on Window.SystemBackdrop.

-parameters

-param connectedTarget

The target of the backdrop.

-param xamlRoot

The XAML root of the backdrop target.

-remarks

This method is called when this SystemBackdrop is attached to a valid container; that is, when it's assigned to the SystemBackdrop property of an object that implements ICompositionSupportsSystemBackdrop, such as Window.SystemBackdrop.

Override this method to create and configure the underlying ISystemBackdropController and its SystemBackdropConfiguration.

-see-also

OnTargetDisconnected

-examples

See SystemBackdrop for the full example.

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