2016-02-13 53 views
0

我想添加使用C#(不使用XAML)的windows phone 8.1應用程序中的圖片所示類似的網格。在Windows 8.1運行時應用程序中動態添加3x10 = 30個網格

enter image description here

我的代碼如下所示:

在XAML:

<Grid Grid.Row="1" x:Name="ContentRoot" Margin="19,9.5,19,0"> 

    </Grid> 

在C#代碼背後:

private void Page_Loaded(object sender, RoutedEventArgs e) 
{ 
    for (int i = 1; i <= 30; i++) 
    { 
     Grid grid = new Grid(); 
     grid.Background = new SolidColorBrush(Colors.Red); 
     TextBlock intro = new TextBlock() 
     { 
     Text = i, 
     FontSize = 10 
     }; 
     grid.Children.Add(intro); 
     ContentRoot.Children.Add(grid); 
    } 
} 

是否有可能增加入口主題轉換/通過C#代碼在這些網格上動畫?

在此先感謝!

+0

看看* GridView *。 – Romasz

+0

我看着它,但不知道如何開始。謝謝! –

+0

也許你可以看看[這個答案](http://stackoverflow.com/a/33593044/2681948)。 – Romasz

回答

0

是的,你可以添加transistion動畫給孩子。

試試下面的代碼:

TransitionCollection tc = new TransitionCollection(); 
EntranceThemeTransition ett = new EntranceThemeTransition() { FromHorizontalOffset = 200, FromVerticalOffset = 200 }; 

ContentRoot.ChildrenTransitions = tc; 

ContentRoot.ChildrenTransitions.Add(ett); 

希望它能幫助! :)

相關問題