WPF窗口fadeIn不工作
我有以下代码:WPF窗口fadeIn不工作,wpf,window,fadein,Wpf,Window,Fadein,我有以下代码: <Window.Background> <SolidColorBrush Opacity="0.7" Color="White" x:Name="BackgroundBrush"></SolidColorBrush> </Window.Background> <Window.Triggers> <EventTrigger RoutedEvent="Loaded"> <Ev
<Window.Background>
<SolidColorBrush Opacity="0.7" Color="White" x:Name="BackgroundBrush"></SolidColorBrush>
</Window.Background>
<Window.Triggers>
<EventTrigger RoutedEvent="Loaded">
<EventTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:5" Storyboard.TargetName="BackgroundBrush" From="0.7">
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger.EnterActions>
</EventTrigger>
</Window.Triggers>
但当窗口显示时,什么也没发生。为什么?
true
,这也需要将设置为None
。(您需要创建自己的标准窗口按钮)除了H.B.所说的之外,您还需要将BeginStoryboard添加到集合中,而不是EnterActions集合中。所以这是可行的:
<Window.Background>
<SolidColorBrush Opacity="0.7" Color="White" x:Name="BackgroundBrush"></SolidColorBrush>
</Window.Background>
<Window.Triggers>
<EventTrigger RoutedEvent="Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:5" Storyboard.TargetName="BackgroundBrush" From="0.7">
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Window.Triggers>
AllowTransparency为true,WindowsStyle为None,但即使是此代码:也不起作用