简体   繁体   English

如何修改亚克力材质的透明度

[英]How to modify the transparency of acrylic material

I'm trying to learn a few things about UWP through an example I downloaded from GitHub (I am totally amateur about UWP and I know it would be best to read a book for beginners) In the example the left pane uses Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" and the right panel uses Background="#7F000000"我正在尝试通过从 GitHub 下载的示例了解有关 UWP 的一些知识(我对 UWP 完全是业余爱好者,我知道最好为初学者阅读一本书) ThemeResource ApplicationPageBackgroundThemeBrush}”,右侧面板使用 Background="#7F000000"

In the right panel, I understood how to change the color and the percentage of transparency.在右侧面板中,我了解了如何更改颜色和透明度百分比。 But I didn't understand how to do this on the left panel.但我不明白如何在左侧面板上执行此操作。

EDIT: and why does the top left edge have white pixelated artifacts?编辑:为什么左上边缘有白色像素化伪影?

<Page
x:Class="AcrylicControls.Example.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:resources="using:AcrylicControls.Example.Resources"
mc:Ignorable="d" d:DesignWidth="600">
<Page.Resources>
    <resources:Lorem x:Key="Lorem"/>

    <DataTemplate x:Key="ExampleListViewItem"
                  x:DataType="x:String">
        <TextBlock Text="{Binding}"
                   ToolTipService.ToolTip="This item does nothing"/>
    </DataTemplate>
</Page.Resources>

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <RelativePanel x:Name="AcrylicBackground" 
                   Grid.Column="0" 
                   Grid.ColumnSpan="2"
                   MinWidth="40" 
                   SizeChanged="Page_SizeChanged"/>
    <Grid Column="0"
          Width="{Binding Width, ElementName=AcrylicBackground}"
          Background="{StaticResource SystemControlAcrylicWindowBrush}">
        <ListView Width="150" 
                  ItemTemplate="{StaticResource ExampleListViewItem}">
            <x:String>Item 1</x:String>
            <x:String>Item 2</x:String>
            <x:String>Item 3</x:String>
            <x:String>Item 4</x:String>
            <x:String>Test</x:String>
        </ListView>
    </Grid>
    
    <Grid Column="1"
          Background="#7F000000">
        <Pivot Title="I'm sample content. Look at me!">
            <PivotItem Header="Lorem Ipsum">
                <TextBlock Text="{Binding Source={StaticResource Lorem}, Path=Ipsum}"
                           TextWrapping="Wrap"/>
            </PivotItem>
            <PivotItem Header="BlurryControls">
                <WebView Source="https://github.com/ConfusedHorse/BlurryControls"/>
            </PivotItem>
        </Pivot>
    </Grid>
</Grid>

Sample Picture示例图片

I tried your code but it shows totally different behavior.我尝试了您的代码,但它显示出完全不同的行为。 The left panel shows the acrylic effect and the right part doesn't have an acrylic effect.左侧面板显示亚克力效果,右侧部分没有亚克力效果。 I guess it caused I'm using part of the code in your sample.我想这是因为我在您的示例中使用了部分代码。

Since you are trying to understand how to use and modify the acrylic material, so I'd like to offer another suggestion for your scenario.由于您正在尝试了解如何使用和修改丙烯酸材料,所以我想为您的场景提供另一个建议。 To understand how to use the acrylic effect, you could take a look at the official document: Acrylic material instead of the third-party library.要了解如何使用亚克力效果,可以看一下官方文档: 亚克力材质而不是第三方库。 The official document introduces the type of acrylic, how to use acrylic and what it looks like.官方文档介绍了亚克力的种类,亚克力的使用方法和外观。 There are also code snippets that are easy to understand and test.还有一些易于理解和测试的代码片段。 For example, it shows how to custom acrylic brush on your own request.例如,它展示了如何根据您的要求定制丙烯酸刷。

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

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