Reputation:
How to fade background WPF image?
My XAML looks like this:
<Grid.Background>
<ImageBrush ImageSource="themes\backpic.png" Stretch="UniformToFill">
</ImageBrush>
</Grid.Background>
I have tried something like:
<Grid.Background>
<ImageBrush ImageSource="pics\bl.png" Stretch="UniformToFill">
<ImageBrush.Transform>
<!-- some code here-->
</ImageBrush.Transform>
</ImageBrush>
</Grid.Background>
Upvotes: 2
Views: 801
Reputation: 128013
Start a DoubleAnimation of the ImageBrush's Opacity property:
<Grid>
...
<Grid.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Background.Opacity"
To="0" Duration="0:0:2"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
...
</Grid>
Upvotes: 6