-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)
Called when this object is attached to a valid container; for example, when set on Window.SystemBackdrop
.
The target of the backdrop.
The XAML root of the backdrop target.
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 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);
}