私が行うためにラベルの内容をアニメーション化しようとしています表示されていません。コードの下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の昇給トリガの = Trueの場合、私はラベルスタイル適用した場合の例については、以下のよう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!迅速なテストを行うために、私はあなたのソリューションの第2を試しました。ラベルスタイルのトリガを設定しましたが、動作しません。ラベルの内容は常に「読み込み中」のままです。私はウィンドウとこのラベルを持つMVVMアプリケーションを持っており、このウィンドウはスプラッシュ画面です。このスプラッシュ画面は、ビューコンストラクタから(インスタンス化コンストラクタによって)呼び出されます。最後にShow()を呼び出すことで表示されます。これらすべてのものは、アパートの状態がSTAに設定されたスレッドを使用しています。 – user1624552
...その間、ビューコンストラクタでは、フローが続行され、viewModelでdatacontextを設定し、ビューでデータベース要求が実行されますモデルコンストラクタ。これが完了すると、スプラッシュ画面が閉じます。たぶん、それは動作していないスレッドのためですか? – user1624552
私が言ったように、あなたのトリガーがIsEnabledに作用してfalseに設定されていることは奇妙に思えます。それは意図されていますか? – Clemens