我無法在Windows 8中執行一個Metro風格的C#/ XAML應用程序中的控制高度的一個簡單的基於故事板的動畫如何動畫控制的高度在Windows 8 XAML
以下瑣碎的XAML並片段後面的代碼工作在Silverlight 5和Windows Phone 7罰款,但在Windows 8中什麼也不做(至少對我來說):
<Page.Resources>
<Storyboard x:Name="expandAnimation">
<DoubleAnimation Storyboard.TargetName="scaleButton" Storyboard.TargetProperty="Height" From="50" To="200" Duration="0:0:1"/>
</Storyboard>
</Page.Resources>
<StackPanel Width="200">
<Button x:Name="scaleButton" Click="scaleButton_Click" Content="Scale"/>
<Button Content="Another button"/>
<Button Content="Yet another button"/>
</StackPanel>
C#代碼:
private void scaleButton_Click(object sender, RoutedEventArgs e)
{
expandAnimation.Begin();
}
相同的代碼可被改變以激活控制的其他屬性,如不透明度,其按預期工作。
我可以動畫一個ScaleTransform進行縮放,但它改變了控件的內部渲染,並不影響相鄰控件的佈局,這對我來說是個問題。
希望我不會在這裏錯過任何明顯的東西,但不應該這只是工作?
非常感謝@Sofian!將'EnableDependentAnimation ='True''添加到上面的xaml中的DoubleAnimation元素中,就可以實現。 – Pete
非常感謝,但你能解釋這個屬性是做什麼的。 – Stilgar
@Stilgar http://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj819807#dependent解釋原因 – legends2k