WPFã®æç»
åå°ã§ã³ã³ããã¼ã«ã®æç»ã«ã¤ãã¦è©±é¡ã«ãªã£ã¦ããã®ã§WPFã使ã£ã¦CheckBoxã400åã»ã©è¡¨ç¤ºãã¦ã¿ã¾ããã(追è¨)ãµã³ãã«ãä¿®æ£ãã¾ããã
ã¦ã£ã³ãã¦ã®ãªãµã¤ãºã¯èªåçã«ãµã¤ãºèª¿æ´ããã®ã§éãã§ãããæç»èªä½ã¯è»½ãã¨æãã¾ããæ¯è¼å¯¾è±¡ããªãã®ã§æè¦ã«éãã¾ãããã2000åã®ãã§ãã¯ããã¯ã¹ã«å¯¾ãããã§ãã¯ã®åãæ¿ãã«1ç§å¼·ãããã§ãã(Athlon64 2.2GHz+GeForce FX 5700)ãããããXAMLã®ãµã³ãã«ã¯è¦ããã¾ããã½ã¼ã¹ã³ã¼ãã®ãµã³ãã«ãå°ãªãã¦ãæå¤ã¨æãããã¾ããã(^^;
using System; using System.Windows; using System.Windows.Controls; namespace MyFirstAvalonApp { public partial class Window1 : Window { const int ROWS = 50; const int COLS = 40; Grid grid; public Window1 () { this.Title = "CheckBox Sample"; grid = new Grid (); for (int i = 0; i < COLS; ++i) { ColumnDefinition cd = new ColumnDefinition (); grid.ColumnDefinitions.Add (cd); } for (int i = 0; i < ROWS; ++i) { RowDefinition rd = new RowDefinition (); grid.RowDefinitions.Add (rd); } for (int i = 0; i < ROWS; ++i) { for (int j = 0; j < COLS; ++j) { CheckBox cb = new CheckBox (); cb.Content = String.Format("{0},{1}", i, j); cb.IsChecked = true; Grid.SetRow (cb, i); Grid.SetColumn (cb, j); grid.Children.Add (cb); } } Button button = new Button (); button.Content = "Click me"; button.Click += OnClick; DockPanel dp = new DockPanel (); DockPanel.SetDock (button, Dock.Bottom); dp.Children.Add (button); dp.Children.Add (grid); this.AddChild (dp); } void OnClick (object sender, RoutedEventArgs e) { foreach (CheckBox cb in grid.Children) cb.IsChecked = !cb.IsChecked; } } }
ã©ã¼ã§ããã話ã§ãããWPFãããAvalonã®æ¹ãã«ãã³ã¤ã¤ã¨æãã®ã§ããã