邀请测试Silverlight性能
本贴在 http://topic.csdn.net/u/20100422/18/c395942e-c682-471f-9c29-dcd424e9cf90.html?seed=1854292371&r=64941195#r_64941195 中已经发过了,为了不影响原贴,特开此新贴,邀请有兴趣者共同测试。
说明:本测试所假定的场景是在 Grid 中创建大量的行和列,这应当是一种极少会被使用到的场景,所以本测试仅供娱乐,也可能没有实际商业应用的意义。
<Grid x:Name="LayoutRoot" Background="White"> <ComboBox Name="comboBox1" Margin="12,12,0,0" HorizontalAlignment="Left" Width="114" Height="23" VerticalAlignment="Top"> <ComboBoxItem Content="Item1" /> </ComboBox> <Button Content="Show ChildWindow" Height="23" HorizontalAlignment="Left" Margin="132,12,0,0" Name="button1" VerticalAlignment="Top" Width="114" Click="button1_Click" /> <sdk:AutoCompleteBox Height="28" HorizontalAlignment="Left" Margin="252,7,0,0" Name="autoCompleteBox1" VerticalAlignment="Top" Width="120" /> <ScrollViewer Margin="13,50,12,12" > <Grid Name="grid1" /> </ScrollViewer></Grid>
public partial class MainPage : UserControl{ public MainPage() { InitializeComponent(); this.autoCompleteBox1.ItemsSource = new string[] {"1","10","100","2","20","200"}; this.GenerateMassControls(100,10); // 可以换成 1000,10再试试 } private void button1_Click(object sender, RoutedEventArgs e) { new System.Windows.Controls.ChildWindow().Show(); } void GenerateMassControls(int rows , int cols) { for (int i = 0; i < rows; i++) { this.grid1.RowDefinitions.Add( new RowDefinition() { Height = new GridLength(28) }); } for (int j = 0; j < cols; j++) { this.grid1.ColumnDefinitions.Add( new ColumnDefinition() { Width = new GridLength(88) }); } for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { FrameworkElement fe = new TextBox() { Text = string.Format("{0}行{1}列" , i , j ), Width=80,Height=23 }; Grid.SetRow(fe, i); Grid.SetColumn(fe, j); this.grid1.Children.Add(fe); } } }}