microsoft / Windows.UI.Composition-Win32-Samples

Windows.UI.Composition Win32 Samples
MIT License
469 stars 186 forks source link

Is that possible to use Composition AcrylicBrush in .NET8 WPF apps? #134

Open SlimeNull opened 3 months ago

SlimeNull commented 3 months ago

I have made a lot of attempts, but eventually stopped at using Win2D.

.NET8 could not use Microsoft.graphics.canvas.winmd

image

robmikh commented 3 months ago

This is doable in theory but a bit tricky in practice. You'll need to include the CsWinRT nuget package and add the CsWinRTIncludes tag to your project file, along with the namespaces you want to generate bindings for (e.g. Microsoft.Graphics.Canvas).

In practice for Win2D, this is difficult because of certain namespace dependencies that aren't supported by CsWinRT. Mainly these are the XAML bits of the API, as well as some of the text portions.

You theoretically don't need Win2D itself, you just need to implement the right interfaces and provide the underlying D2D properties for the effect definitions. I had a project in the past that implemented a subset of the effect definitions here: https://github.com/robmikh/Robmikh.Interop.Composition

Most of us are on holiday at the moment, but I'll see if I can whip up a sample using Win2D when I get back.