'Problems with XamlCompositionBrushBase in UWP C#

I've made a acrylic brush clone in C#. It works perfectly when I've running it with battery saver is disabled before running app, but when I'm enabling the battery saver and running it again, it does not enabling transparency when I'm disabling the battery saver when app is running. The same is with transparency toggle in Settings menu in Windows. So there is any way to reload the brush when battery saver is disabled (for example) in running app?

Here is the code:

        bool isWindowed = BackgroundSource == CustomAcrylicBackgroundSource.Hostbackdrop;
        if (useFallback == false && (DefaultTheme.AdvancedEffectsEnabled && PowerManager.EnergySaverStatus != EnergySaverStatus.On)
            && !(UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Touch && isWindowed))
        {
            ArithmeticCompositeEffect crossFadeEffect = new ArithmeticCompositeEffect
            {
                MultiplyAmount = 0f,
                Source1Amount = (float)TintOpacity,
                Source2Amount = 1 - (float)TintOpacity,
                Source1 = new ColorSourceEffect
                {
                    Color = TintColor
                },
                Source2 = new ArithmeticCompositeEffect
                {
                    MultiplyAmount = 0f,
                    Source1Amount = sc_noiseOpacity,
                    Source2Amount = 0.98f,
                    Source1 = new BorderEffect
                    {
                        Source = new CompositionEffectSourceParameter("image"),
                        ExtendX = CanvasEdgeBehavior.Wrap,
                        ExtendY = CanvasEdgeBehavior.Wrap,
                    },
                    Source2 = new BlendEffect
                    {
                        Mode = BlendEffectMode.Exclusion,
                        Foreground = new ColorSourceEffect
                        {
                            Color = Sc_exclusionColor
                        },
                        Background = new SaturationEffect
                        {
                            Saturation = sc_saturation,
                            Source = new GaussianBlurEffect
                            {
                                BlurAmount = sc_blurRadius,
                                BorderMode = EffectBorderMode.Hard,
                                Name = "Blur",
                                Optimization = EffectOptimization.Balanced,
                                Source = new CompositionEffectSourceParameter("source")
                            }
                        }
                    }
                }
            };

            CompositionEffectFactory effectFactory = compositor.CreateEffectFactory(crossFadeEffect);
            effectBrush = effectFactory.CreateBrush();

            LoadedImageSurface imagesurface = LoadedImageSurface.StartLoadFromUri(new Uri("ms-appx:///UnitedCodebase/Assets/NoiseAsset_256X256_PNG.png"));

            CompositionSurfaceBrush imagebrush = compositor.CreateSurfaceBrush(imagesurface);
            imagebrush.Stretch = CompositionStretch.None;
            effectBrush.SetSourceParameter("image", imagebrush);

            if (BackgroundSource == CustomAcrylicBackgroundSource.Hostbackdrop)
            {
                backdropBrush = compositor.CreateHostBackdropBrush();
            }
            else
            {
                backdropBrush = compositor.CreateBackdropBrush();
            }

            effectBrush.SetSourceParameter("source", backdropBrush);

            CompositionBrush = effectBrush;
        }
        else
        {
            CompositionBrush = compositor.CreateColorBrush(FallbackColor);
        }

    private void DisconnectAcryilicBrush()
    {
        if (backdropBrush != null)
        {
            backdropBrush.Dispose();
            backdropBrush = null;
        }

        if (CompositionBrush != null)
        {
            CompositionBrush.Dispose();
            CompositionBrush = null;
        }
    }

Usage:

    protected override void OnConnected()
    {
        bool usingFallback;

        if (BackgroundSource == CustomAcrylicBackgroundSource.Hostbackdrop)
        {
            usingFallback = !CompositionCapabilities.GetForCurrentView().AreEffectsSupported();
        }
        else
        {
            usingFallback = !CompositionCapabilities.GetForCurrentView().AreEffectsFast();
        }

        ConnectAcrylicBrush(usingFallback);

        base.OnConnected();
    }


    protected override void OnDisconnected()
    {
        DisconnectAcryilicBrush();

        base.OnDisconnected();
    }


Solution 1:[1]

So there is any way to reload the brush when battery saver is disabled (for example) in running app?

I have to say that is not possible. The transparency effect is controlled by the system. When the transparency effect feature is disabled from the Settings page, all the transparency effects will not work.

This is also mentioned in this document: Acrylic material. From the red note, it says Rendering acrylic surfaces is GPU-intensive, which can increase device power consumption and shorten battery life. Acrylic effects are automatically disabled when a device enters Battery Saver mode. Users can disable acrylic effects for all apps by turning off Transparency effects in Settings > Personalization > Colors.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Roy Li - MSFT