How to get the compositor instance while handling XamlCompositionBrushBase.OnConnected in a WinUI-3 desktop app

Viewed 32
1 Answers

Ok, as often it gets easy as soon as the matching documentation is found:

In XAML apps, we recommend that you call ElementCompositionPreview.GetElementVisual(UIElement) to get a Composition Visual, and get the Compositor from the visual's Compositor property. In cases where you don't have access to a UIElement (for example, if you create a CompositionBrush in a class library), you can call CompositionTarget.GetCompositorForCurrentThread to get the Compositor instead.

Related issue.

Related Issue.

Related