c# - 使用 XamlCompositionBrushBase 时找不到类

标签 c# xaml uwp uwp-xaml windows-composition-api

所以我尝试将 BackdropBrush 与 XamlCompositionBrushBase 结合使用,创建一个名为 BackdropBlurBrush 的类,但是当我从 XAML 调用它时 它找不到该类。 我在主项目上创建了类。 See the error here.

GitHub 上的示例:https://github.com/vitorgrs/HostBackdrop/

最佳答案

您的自定义组合画笔不是UIElement,这就是为什么它不能直接放在 XAML 可视化树上的原因。

尝试将它添加为元素的画笔 -

<Grid>
    <Grid.Background>
        <local:BackdropBlurBrush BlurAmount="5" />
    </Grid.Background>
</Grid>

您通常希望像这样将模糊画笔放在背景图像的顶部 -

<Grid x:Name="Root">
    <Grid.Background>
        <ImageBrush Stretch="UniformToFill" ImageSource="background.jpg"/>
    </Grid.Background>

    <Rectangle>
        <Rectangle.Fill>
            <local:BackdropBlurBrush BlurAmount="5" />
        </Rectangle.Fill>
    </Rectangle>
</Grid>

enter image description here

关于c# - 使用 XamlCompositionBrushBase 时找不到类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45122924/

相关文章:

c# - 在运行时使用和调用 SOAP Web 服务 - 来自 WSDL 文件的动态 Web 服务客户端

c# - WPF DataGrid 中的自定义 StringFormat

c# - 在 C# 中更改系统图标

wpf - 如何在其单元格之一无效时编辑 wpf datagrid 其他单元格?

c# - Windows 10 UWP - 如果前台应用程序正在运行,则停止后台任务

c# - TcpClient 读取 OutOfMemoryException

c# - 序列化包含 XDocument 的属性

c# - 在 .NET 中使用 Ambient 属性?

visual-studio-2015 - 如何调试 XAML 设计器问题?

c# - RestSharp.Portable - IgnoreResponseStatusCode 属性不适用于 UWP 应用程序?