0
を動作しません:バインディングストーリーボードは、私が実際の高さに固定高さからスタックパネルを展開したい
<DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(FrameworkElement.MaxHeight)" Storyboard.TargetName="stpAbout">
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="{Binding ActualHeight, ElementName=stpAbout, Mode=OneWay}">
<EasingDoubleKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseOut" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
スタックパネル:
<StackPanel x:Name="stpAbout" MaxHeight="200">
ストーリーボードを実行するコード:
var dia = new MessageDialog(stpAbout.ActualHeight.ToString());
await dia.ShowAsync(); // Shows an actual height of 312
var sbExpand = (Storyboard)Resources["stbExpandAbout"]; // Get the storyboard
sbExpand.Begin(); // Play the storyboard
dia = new MessageDialog(stpAbout.ActualHeight.ToString());
await dia.ShowAsync(); // Shows still an actual heigh of 312
しかし、スタックパネルは展開されません。それは崩壊し、今は全く身長がありません。アニメーション後のアニメーション
前
サンプル
ページ:
<Page
x:Class="Juqe.Client.UWP.Pages.BlankPage1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Juqe.Client.UWP.Pages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<Storyboard x:Name="stbExpand">
<DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(FrameworkElement.MaxHeight)" Storyboard.TargetName="stpToExpand">
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="{Binding ActualHeight, ElementName=stpToExpand, Mode=OneWay}">
<EasingDoubleKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseOut" />
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel>
<StackPanel x:Name="stpToExpand" MaxHeight="96">
<Grid Height="48" Background="Red" />
<Grid Height="48" Background="Green" />
<Grid Height="48" Background="Blue" />
<Grid Height="48" Background="Yellow" />
</StackPanel>
<Button Click="Button_Click">Expand</Button>
</StackPanel>
</Grid>
コード:"ソリューション"
が、私はそれを取得した後、コードでストーリーボードを操作
private async void Button_Click(object sender, RoutedEventArgs e)
{
var dia = new MessageDialog(stpToExpand.ActualHeight.ToString());
await dia.ShowAsync();
var sbExpand = (Storyboard)Resources["stbExpand"]; // Get the storyboard
sbExpand.Begin(); // Play the expand storyboard
sbExpand.Completed += async (se, ev) =>
{
dia = new MessageDialog(stpToExpand.ActualHeight.ToString());
await dia.ShowAsync();
};
}
:
((storyboard.Children[0] as DoubleAnimationUsingKeyFrames).KeyFrames[0] as EasingDoubleKeyFrame).Value = stpAbout.ActualHeight; // Correct the storyboard
MaxHeightが最初に200に設定されている場合、ActualHeightはどのように312になりますか? – mm8
私はMaxHeightがActualHeightに影響しないと思います。私は確信していなかったので、私は2つのダイアログを示し、それは両方の時間312を示した。 –
問題を再現可能なサンプルとして質問してください。あなたはこれを読んでください:http://stackoverflow.com/help/mcve – mm8