この質問をする前に、私はそれを検索しましたが、私のケースは異なります。 Storyboard Storyboard to StoryboardオブジェクトViewmodel
<Storyboard x:Key="Storyboard1" >
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="rectangle">
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="180"/>
<EasingDoubleKeyFrame KeyTime="0:0:4" Value="360"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="smartphone_png">
<SplineDoubleKeyFrame KeyTime="0:0:1.6" Value="205.5"/>
<SplineDoubleKeyFrame KeyTime="0:0:2.2" Value="205.5"/>
<EasingDoubleKeyFrame KeyTime="0:0:4" Value="466.667"/>
<EasingDoubleKeyFrame KeyTime="0:0:5" Value="466.667"/>
<EasingDoubleKeyFrame KeyTime="0:0:6" Value="632.334"/>
<EasingDoubleKeyFrame KeyTime="0:0:7" Value="706.001"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="smartphone_png">
<EasingDoubleKeyFrame KeyTime="0:0:6" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:7" Value="53.333"/>
<EasingDoubleKeyFrame KeyTime="0:0:8" Value="196.166"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
と、このユーザーコントロールのためのViewModelで
が、私はStoryboard1ストーリーボードに結合するために、このような何かを持っている:Storyboard BoardControl = new Storyboard();
var resource =?? \\this line is what I need to bind to Storyboard1
BoardControl = resource as Storyboard;
BoardControl.Stop();
私は試したことがあり: 私はそのようなユーザーコントロールの名前付きストーリーボードを持って
オブジェクトリソース= Application.Current.TryFindResource( "Storyboard1");
新しいStoryboard1オブジェクトを初期化するように思われたため、間違っていました。最初と同じオブジェクトではありませんでした。
私のための任意のアイデア、事前に感謝します。
がなぜ作成するか、またはあなたのビューモデルでストーリーボードを使用しようとしている:あなたは、このような
Storyboard
リソースにアクセスすることができますか?ストーリーボードはビューに属します。 – mm8