简体   繁体   English

如何将特定图像设置为Fluent Design AcrylicBackgroundSource

[英]How to set a specific image as a Fluent Design AcrylicBackgroundSource

How to set an specific image as a Fluent Design AcrylicBackgroundSource to use in PIP mode ( CompactOverlay ) like Groove Music PIP feature 如何将特定图像设置为AcrylicBackgroundSource Design AcrylicBackgroundSource以在PIP模式( CompactOverlay )中使用,例如Groove Music PIP功能

在此处输入图片说明

The picture-in-picture in UWP applications is strictly a compressed version of the current page. UWP应用程序中的画中画严格来说是当前页面的压缩版本。 You may see the difference between Groove in normal view and compression attempts, but the principle of implementing Acrylic Brush is the same. 您可能会看到常规视图中的Groove与压缩尝试之间的区别,但是实现Acrylic Brush的原理是相同的。

Considering the question you asked, here is a possible way to achieve image blur: 考虑到您提出的问题,这是实现图像模糊的一种可能方法:

XAML XAML

<Page
    ...>
    <Page.Resources>
        <ImageBrush ImageSource="{Here is your image url}" x:Key="ImageBackground" Stretch="UniformToFill"/>
        <AcrylicBrush x:Key="MaskBackground" BackgroundSource="Backdrop" TintColor="Black" TintOpacity="0.3" FallbackColor="Black"/>
    </Page.Resources>

    <Grid Background="{StaticResource ImageBackground}" Name="ImageLayer">
        <Grid Background="{StaticResource MaskBackground}" Name="MaskLayer"/>

        <Grid>
            <!-- Here is other controls, like play button etc. -->
        </Grid>
    </Grid>
</Page>

Usage 用法

This is done using a layer approach. 这是使用分层方法完成的。 Set the background to a picture, then add a mask layer. 将背景设置为图片,然后添加遮罩层。

If you want to change the background image dynamically, you can remove the static reference and change it with C# code. 如果要动态更改背景图像,则可以删除静态引用并使用C#代码对其进行更改。

var backgroundBrush = new ImageBrush();
backgroundBrush.ImageSource = new BitmapImage(new Uri("Here is your image url"));
ImageLayer.Background = backgroundBrush;

Best regards. 最好的祝福。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM