为什么 UWP 不支持 Acrylic Brush?
Why is Acrylic Brush Not Supported in UWP?
我已经创建了一个基本的 UWP 应用程序,当我尝试像这样使用亚克力画笔时:
<Page
x:Class="LearningUWP.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:LearningUWP"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
// Acrylic brush here
<Page.Resources>
<media:AcrylicBrush x:Key="HostBackdropBrush"
BackgroundSource="HostBackdrop"
TintColor="LightBlue"
TintOpacity="0.6"
FallbackColor="LightSkyBlue"
FallbackForced="False" />
</Page.Resources>
<Grid>
<Button Content="Synthesize" Margin="528,88,0,0" VerticalAlignment="Top" Height="93" Width="222" Click="Button_Click"/>
<TextBox x:Name="Text" HorizontalAlignment="Left" Height="145" Margin="39,62,0,0" Text="Hello, World!" TextWrapping="Wrap" VerticalAlignment="Top" Width="389"/>
</Grid>
</Page>
Visual Studio 表示 Acrylic Brush is not supported in UWP
。
我是Windows10 1903(这也是我的目标版本),我的最低版本是1803。
我找到了一个方法:
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<AcrylicBrush x:Key="MyAcrylicBrush"
BackgroundSource="HostBackdrop"
TintColor="Black"
TintOpacity="0.5"
TintLuminosityOpacity="1"
FallbackColor="#111111"
/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
</Page.Resources>
通过将以上代码添加到我的 <Page>
中并设置 <Grid>
背景如下:
<Grid Background="{ThemeResource MyAcrylicBrush}">
其中 MyAcrylicBrush
是 AcrylicBrush
的 x:Key
。
Why is Acrylic Brush Not Supported in UWP?
AcrylicBrush
is available from 16299, it could work in 1803 min version (17134), your compile error is used media:
namespace, but you have not referred WinUI nugget package, and if your mini 1809, you have no need add media
namespace. you just give it a x:key
and use StaticResource
参考丙烯画笔。
我已经创建了一个基本的 UWP 应用程序,当我尝试像这样使用亚克力画笔时:
<Page
x:Class="LearningUWP.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:LearningUWP"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
// Acrylic brush here
<Page.Resources>
<media:AcrylicBrush x:Key="HostBackdropBrush"
BackgroundSource="HostBackdrop"
TintColor="LightBlue"
TintOpacity="0.6"
FallbackColor="LightSkyBlue"
FallbackForced="False" />
</Page.Resources>
<Grid>
<Button Content="Synthesize" Margin="528,88,0,0" VerticalAlignment="Top" Height="93" Width="222" Click="Button_Click"/>
<TextBox x:Name="Text" HorizontalAlignment="Left" Height="145" Margin="39,62,0,0" Text="Hello, World!" TextWrapping="Wrap" VerticalAlignment="Top" Width="389"/>
</Grid>
</Page>
Visual Studio 表示 Acrylic Brush is not supported in UWP
。
我是Windows10 1903(这也是我的目标版本),我的最低版本是1803。
我找到了一个方法:
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<AcrylicBrush x:Key="MyAcrylicBrush"
BackgroundSource="HostBackdrop"
TintColor="Black"
TintOpacity="0.5"
TintLuminosityOpacity="1"
FallbackColor="#111111"
/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
</Page.Resources>
通过将以上代码添加到我的 <Page>
中并设置 <Grid>
背景如下:
<Grid Background="{ThemeResource MyAcrylicBrush}">
其中 MyAcrylicBrush
是 AcrylicBrush
的 x:Key
。
Why is Acrylic Brush Not Supported in UWP?
AcrylicBrush
is available from 16299, it could work in 1803 min version (17134), your compile error is used media:
namespace, but you have not referred WinUI nugget package, and if your mini 1809, you have no need add media
namespace. you just give it a x:key
and use StaticResource
参考丙烯画笔。