我想做一些可能有点棘手的事情,因为它是Win 10 Creators Update中的一项新功能:我想使用新的Acrylic Accent功能在UWP应用程序中制作透明的Windows。 我看到微软已经在Fast Insider Ring中引入了Groove和Film &电视。如何在Windows 10 Creators中正确使用Acrylic Accent(CreateHostBackDropBrush())?
这是我开发的,采用在Win开发中心的例子和一些其他的答案在这里堆栈溢出代码:
public sealed partial class MainPage : Page
{
// Some other things
private void initializeInterface()
{
/// Applying Acrylic Accent
LayoutRoot.Background = null;
GaussianBlurEffect blurEffect = new GaussianBlurEffect()
{
Name = "Blur",
BlurAmount = 5.0f,
BorderMode = EffectBorderMode.Hard,
Optimization = EffectOptimization.Balanced,
Source = new CompositionEffectSourceParameter("source"),
};
LayoutRoot.Background = null;
var rootVisual = ElementCompositionPreview.GetElementVisual(LayoutRoot as UIElement);
var compositor = rootVisual.Compositor;
var factory = compositor.CreateEffectFactory(blurEffect);
var effectBrush = factory.CreateBrush();
// This is the effect I wanted to use, the "Acrylic Accent", as it is called by MS itself.
var backdropBrush = compositor.CreateHostBackdropBrush();
effectBrush.SetSourceParameter("source", backdropBrush);
var blurVisual = compositor.CreateSpriteVisual();
blurVisual.Brush = effectBrush;
ElementCompositionPreview.SetElementChildVisual(LayoutRoot as UIElement, blurVisual);
}
}
哪里LayoutRoot
是用作根面板RelativePanel
。
但是有些东西不起作用:什么? 如何将它应用于UIElement
,如Page
或Panel
?
我真的很感谢你的帮助,谢谢。
能否请你加你用来解决自己的问题的代码? – WJM
WJM,现在就做,享受。 ;) – LucaLindholm
@WJM,做到了......享受。 ;) – LucaLindholm