我想動畫網格行高度變化,但如何做到這一點與動態「星級」高度值?動畫網格行高度變化WP
我有以下電網:
<Grid x:Name="baseGrid">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="3*"/>
</Grid.RowDefinitions>
<Grid x:Name="grid0" Grid.Row="0" Tap="grid0_Tap">
// Content
</Grid>
<Grid x:Name="grid1" Grid.Row="1" Tap="grid1_Tap">
// Content
</Grid>
<Grid x:Name="grid2" Grid.Row="2">
// Content
</Grid>
</Grid>
在後面的代碼我的邏輯是,如果用戶點擊grid0,GRID2獲取隱藏。同樣,如果用戶點擊grid1,grid2會返回它的大小。
private void grid0_Tap(object sender, RoutedEventArgs e)
{
this.LayoutRoot.RowDefinitions[2].Height = new GridLength(0);
}
private void grid1_Tap(object sender, RoutedEventArgs e)
{
this.LayoutRoot.RowDefinitions[2].Height = new GridLength(3, GridUnitType.Star);
}
這現在運作良好,但如何動畫呢?我認爲Storyboard需要從/到價值,因爲使用動態尺寸的Im我不能使用Storyboard?
的問題不清楚。 「grid3被隱藏」,但沒有在您的XAML中定義「grid3」。 –
對不起,混合了網格名稱。固定... – devha