내가하기 위해 라벨의 내용을 애니메이션을 시도하고 표시되지 않는 . 코드 아래C# WPF 애니메이션 라벨의 콘텐츠는
:
<Label Grid.Row="2" x:Name="CurrentTask"
FontFamily="Microsoft Sans Serif" FontSize="18" FontStyle="Italic" FontWeight="Bold"
Foreground="White" Content="Loading">
<Label.Template>
<ControlTemplate>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="Content" Duration="00:00:00.8" RepeatBehavior="Forever">
<DiscreteObjectKeyFrame KeyTime="00:00:00.0" Value="Loading"/>
<DiscreteObjectKeyFrame KeyTime="00:00:00.2" Value="Loading."/>
<DiscreteObjectKeyFrame KeyTime="00:00:00.4" Value="Loading.."/>
<DiscreteObjectKeyFrame KeyTime="00:00:00.6" Value="Loading..."/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Label.Template>
</Label>
문제는 라벨의 내용이 WPF 창에 표시되지 않는 것입니다. 그것은 보이지 않고있다. 내가 도대체 뭘 잘못하고있는 겁니까? 형의 라인 또한
:
<DiscreteObjectKeyFrame KeyTime="00:00:00.0" Value="Loading"/>
대신 하드 코딩 나는 도트 라벨의 내용을 연결하고자하는 값을, 난 할 수 있습니까? 각 DiscreteObjectKeyFrame
에 "로드 중"문자열을 반복하고 싶지 않습니다.
UPDATE 대신의 IsEnabled에 인상 트리거의 = 사실, 나는 레이블 스타일 적용하는 경우에 예를 들어 다음과 같이 label.loaded 사용했다 : 트리거 외에
<Label Grid.Row="2" x:Name="CurrentTask"
FontFamily="Microsoft Sans Serif" FontSize="18" FontStyle="Italic"
Foreground="White" Content="Loading">
<Label.Style>
<Style TargetType="Label">
<Style.Triggers>
<EventTrigger RoutedEvent="Label.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Content" Duration="00:00:00.8" RepeatBehavior="Forever">
<DiscreteObjectKeyFrame KeyTime="00:00:00.0" Value="Loading"/>
<DiscreteObjectKeyFrame KeyTime="00:00:00.2" Value="Loading."/>
<DiscreteObjectKeyFrame KeyTime="00:00:00.4" Value="Loading.."/>
<DiscreteObjectKeyFrame KeyTime="00:00:00.6" Value="Loading..."/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
안녕 Clemens! 빠른 테스트를 수행하기 위해 라벨 스타일 트리거를 설정하는 두 번째 솔루션을 시도했지만 작동하지 않습니다. 라벨 내용은 항상 "로드 중"상태입니다. 나는 창과이 레이블이있는 MVVM 응용 프로그램을 가지고 있으며이 창은 스플래시 화면입니다. 이 스플래시 화면은 뷰 생성자에서 (생성자를 인스턴스화하여) 호출됩니다. 마지막으로 Show()를 호출하여 표시됩니다. 이 모든 것들이 STA로 설정된 아파트 상태의 쓰레드를 사용하고 있습니다 ... – user1624552
... 그 동안 뷰 생성자에서 플로우가 계속되고 viewModel과 함께 datacontext를 설정 한 다음 데이터베이스 요청이 뷰에서 수행됩니다 모델 생성자. 이 작업이 끝나면 스플래시 화면이 닫힙니다. 어쩌면 그것이 작동하지 않는 스레드 때문일 수 있습니까? – user1624552
내가 말했듯이, 당신의 트리거가 IsEnabled에 대해 false로 설정된 것은 이상하게 보입니다. 그게 의도 된거야? – Clemens