車枠組みの要素から絵コンテ
-
22-07-2019 - |
質問
私への参照をスのインスタンス絵コンテのオブジェクトは、取得したいの枠組みの要素を取り付けて/を使用してアニメーション化.していきたいくないと思うからです。
例えば、ポ示いただく必要がありまからの参照を絵コンテに対する支配を確立するには、ラベルまたはグリッド
<Grid>
<Grid.Resources>
<Storyboard x:Key="myStoryboard">
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="0:0:5"/>
</Storyboard>
<Style x:Key="myStyle" TargetType="{x:Type Label}">
<Style.Triggers>
<DataTrigger
Binding="{Binding Path=StartAnimation}" Value="true">
<DataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource myStoryboard}" />
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<Label x:Name="labelHello" Grid.Row="0" Style="{StaticResource myStyle}">Hello</Label>
</Grid>
の方にぜ地球にいいことでしか作り出してしまおうというものから絵コンテのクラスまたは付属の行動できるかを指定する方法のDataContextされたときに呼び出されますの絵コンテを完了イベントです。このように純ョうな一部のコードを呼び込んモデルです。
解決
変更された場合、それぞれのポうようになります:
<Grid x:Name="grid">
<Grid.Resources>
<Storyboard x:Key="myStoryboard">
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="0:0:5" Storyboard.Target="{Binding ElementName = grid}"/>
</Storyboard>
<Style x:Key="myStyle" TargetType="{x:Type Label}">
<Style.Triggers>
<DataTrigger
Binding="{Binding Path=StartAnimation}" Value="true">
<DataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource myStoryboard}" />
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<Label x:Name="labelHello" Grid.Row="0" Style="{StaticResource myStyle}">Hello</Label>
</Grid>
これをx:名のグリッド部門)を受賞.対象のDoubleAnimation.を取得することができますを参考にグリッドとこのコード:
Storyboard sb = //You mentioned you had a reference to this.
var timeLine = sb.Children.First();
var myGrid = Storyboard.GetTarget(timeLine);
所属していません StackOverflow