I'm trying to apply a background for what ever the control the effect is attached to.
First i made the effect to apply a background for the controls that have either a Fill or Background properties in UWP. But the problem is a lot of controls renderes to FrameworkElement in UWP. And FrameworkElement doesn't have a Background property . In the VisualElementRenderer Xamarin forms adresses this issue be applying a background layer behind the content but this is an effect. Is there is any way to apply a background for whatever the effect is attached to? I'm appplying an AcrylicBrush So it must be assigned to the Control directly.
The code i written before:
try
{
Control.GetType().GetProperty("Background").SetValue(Control, brush);
}
catch
{
Control.GetType().GetProperty("Fill").SetValue(Control, brush);
}
You could use
compositor
to apply Acrylic toSpriteVisual
. We use Win2D to makeGaussianBlurEffect
forUIElement
before we have Acrylic API. GetCompositor
of UIElement, and use thisCompositor
toCreateSpriteVisual
. then setGaussianBlurEffect
tohostSprite.Brush
like the following.And calling it with applyAcrylicAccent(RootLayout). You also will need to handle the
SizeChanged
event :