如何淡化背景WPF图像?
我的XAML看起来像这样:
<Grid.Background>
<ImageBrush ImageSource="themes\backpic.png" Stretch="UniformToFill">
</ImageBrush>
</Grid.Background>
我尝试过类似的事情:
<Grid.Background>
<ImageBrush ImageSource="pics\bl.png" Stretch="UniformToFill">
<ImageBrush.Transform>
<!-- some code here-->
</ImageBrush.Transform>
</ImageBrush>
</Grid.Background>
答案 0 :(得分:5)
启动ImageBrush的Opacity属性的DoubleAnimation:
<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>