Button.Triggerで単純なDoubleAnimationを使用しています。Animation Fromは、ルート要素のActualHeightにバインドされています。これは期待どおりに機能します。
次に、ストーリーボードをVisualStateManagerに移動しようとしました。今、WPFは文句を言います:
System.Windows.Dataエラー:2:ターゲット要素の支配的なFrameworkElementまたはFrameworkContentElementが見つかりません。BindingExpression:Path = ActualWidth; DataItem = null; ターゲット要素は「DoubleAnimation」(HashCode = 29201322)です。ターゲットプロパティは'To'です(タイプ'Nullable`1')
VisualStateManager.VisualStateGroups / VisualState内のアニメーションでバインディングを使用することはできませんか?
そうではないようです。ストーリーボードをリソースに移動することで問題を修正しました。これで、GameToTitleは機能しますが、TitleToGameは失敗します。
これが予想されるかどうかを知りたいのですが。
関連するXAML:
<Grid x:Name="MainInterface">
<Grid.Resources>
<Storyboard x:Key="GameToTitle">
<DoubleAnimation Storyboard.TargetName="GameScreenInterface" Storyboard.TargetProperty="(Control.RenderTransform).(TransformGroup.Children)[1].(TranslateTransform.Y)" From="0" To="{Binding Path=ActualHeight, ElementName=MainInterface}" Duration="0:0:0.2"/>
<DoubleAnimation Storyboard.TargetName="TitleScreenInterface" Storyboard.TargetProperty="(Control.RenderTransform).(TransformGroup.Children)[1].(TranslateTransform.Y)" From="{Binding Path=ActualHeight, ElementName=MainInterface, Converter={Converters:InverseConverter}}" To="0" Duration="0:0:0.2"/>
</Storyboard>
</Grid.Resources>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="TitleScreenState" Storyboard="{StaticResource ResourceKey=GameToTitle}"/>
<VisualState x:Name="GameScreenState">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="GameScreenInterface" Storyboard.TargetProperty="(Control.RenderTransform).(TransformGroup.Children)[1].(TranslateTransform.Y)" From="{Binding Path=ActualHeight, ElementName=MainInterface}" To="0" Duration="0:0:0.2"/>
<DoubleAnimation Storyboard.TargetName="TitleScreenInterface" Storyboard.TargetProperty="(Control.RenderTransform).(TransformGroup.Children)[1].(TranslateTransform.Y)" From="0" To="{Binding Path=ActualHeight, ElementName=MainInterface, Converter={Converters:InverseConverter}}" Duration="0:0:0.2"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<View:TitleScreen x:Name="TitleScreenInterface"/>
<View:GameScreen x:Name="GameScreenInterface" />
</Grid>