왜 Windows 코드 숨김에 다음 이벤트가 적용되지 않습니까?코드 숨김에서 불투명도 변경
void about_Click(object sender, RoutedEventArgs e)
{
// TopLevel.Opacity = 1.0, Splashscreen.Opacity = 0.0
TopLevel.Opacity = 0.1;
// still: TopLevel.Opacity = 1.0
Splashscreen.Opacity = 1.0;
// still: Splashscreen.Opacity = 0.0
}
불투명도 값은 변경되지 않습니다.
<Window.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource splashscreenanimation}" />
</EventTrigger>
</Window.Triggers>
나는 그것을 제거
코드 숨김 노력하고 있습니다 :나는 다음과 같은 트리거 내 문제의 원인임을 발견했다.
<Window.Resources>
<Storyboard x:Key="splashscreenanimation">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"
Storyboard.TargetName="Splashscreen"
BeginTime="0:0:0.900">
<EasingDoubleKeyFrame KeyTime="0:0:1.5"
Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"
Storyboard.TargetName="TopLevel"
BeginTime="0:0:0.900">
<EasingDoubleKeyFrame KeyTime="0:0:1.5"
Value="1" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
Solution : 완성도를 들어
이 애니메이션 당신이 첫번째 실행하여 애니메이션을 제거 할 수 있습니다 뒤에 코드에서 : Splashscreen.BeginAnimation(UserControl.OpacityProperty, null);
은 (스플래시 스크린은 UserControl을)입니다.
나는 또한 FillBehavior="HoldEnd"
또는 FillBehavior="Stop"
을 스토리 보드에 추가하려고 시도했지만 제대로 작동하지 못했습니다.
나는 당신의 마지막 코멘트에 동의하지 않을 것이다. 그것은 나를 위해 잘 작동한다. 아마도이 동작을 나타내는 XAML의 단순화 된 버전을 표시 할 수 있습니까? – Sheridan