如何复制新DropBox UWP应用程序中的窗口透明效果

LeB*_*nes 1 c# xaml uwp uwp-xaml

显然,效果是创作者更新中引入的一项功能.有没有人想出用于解决这个问题的确切API?更好的是一些示例代码,至少可以帮助我开始.

任何帮助将不胜感激.:]

Ole*_*ilo 5

您应该将Windows Creators Update作为目标

 using Windows.UI.Xaml.Hosting;

 //'this' is MainPage, but can be any UIElement
 var visual = ElementCompositionPreview.GetElementVisual(this);
 var brush = visual.Compositor.CreateHostBackdropBrush();
 var sprite = visual.Compositor.CreateSpriteVisual();
 sprite.Brush = brush;
 //Set to the size of the area, update on SizeChanged
 sprite.Size = new System.Numerics.Vector2(1000, 1000); 
 ElementCompositionPreview.SetElementChildVisual(this, sprite);
Run Code Online (Sandbox Code Playgroud)