I want to do something that could be a little bit tricky, since it's a new feature in Win 10 Creators Update: I would like to use the new Acrylic Accent feature to make transparent Windows in UWP apps. I saw that Microsoft is already introducing it in Groove and Film & TV in Fast Insider Ring.
This is the code I developed, using examples in Win Dev Center and some other answers here on Stack Overflow:
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);
}
}
Where LayoutRoot
is a RelativePanel
used as root panel.
But something isn't working: what?
How can I apply it to a UIElement
, like a Page
or a Panel
?
I really would appreciate your help, thanks.