Beispiel #1
0
        private void Setup()
        {
            if (!_firstRun)
            {
                return;
            }
            _firstRun = false;

            var shadowContainer = ElementCompositionPreview.GetElementVisual(ImageContainer);
            var compositor      = shadowContainer.Compositor;

            var image       = ImageContainer.FindChildren <CompositionImage>().First();
            var imageVisual = image.SpriteVisual;

            var imageLoader      = ImageLoaderFactory.CreateImageLoader(compositor);
            var imageMaskSurface = imageLoader.CreateManagedSurfaceFromUri(new Uri("ms-appx:///Helpers/Composition/CircleMask.png"));

            var mask = compositor.CreateSurfaceBrush();

            mask.Surface = imageMaskSurface.Surface;

            var source = image.SurfaceBrush as CompositionSurfaceBrush;

            var maskBrush = compositor.CreateMaskBrush();

            maskBrush.Mask   = mask;
            maskBrush.Source = source;

            image.Brush = maskBrush;
            Shadow.Mask = maskBrush.Mask;

            this.Fade(value: 1, delay: 1000).StartAsync();
        }