Reputation: 53
So I tried to use BackdropBrush with XamlCompositionBrushBase creating a class called BackdropBlurBrush, but when I call it from XAML It doesn’t find the class. I created the class on the main project. See the error here.
Sample on GitHub: https://github.com/vitorgrs/HostBackdrop/
Upvotes: 3
Views: 111
Reputation: 39006
Your custom composition brush is not a UIElement
and that's why it cannot be placed onto the XAML visual tree directly.
Try adding it as a brush for an element -
<Grid>
<Grid.Background>
<local:BackdropBlurBrush BlurAmount="5" />
</Grid.Background>
</Grid>
You normally want to place your blur brush on top of your background image like this -
<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>
Upvotes: 3