using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; namespace SilverlightNaited { public partial class RuutudeArv : UserControl { public RuutudeArv() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { ala1.Children.Clear(); int kogus = Convert.ToInt32(txtKogus.Text); for (int i = 0; i < kogus; i++) { Rectangle r = new Rectangle(); r.Width = 10; r.Height = 10; r.Fill = new SolidColorBrush(Colors.Green); Canvas.SetLeft(r, i * 20); Canvas.SetTop(r, 30); ala1.Children.Add(r); } ala1.UpdateLayout(); } } }