我不能在画布上添加2个以上的控件

时间:2014-06-25 16:15:05

标签: c# xaml canvas windows-phone-8.1

我正在尝试在Windows Phone应用程序的运行时添加控件,但我无法在画布上添加2个以上的控件。我在主屏幕中有一个文本框,用户将输入一个可以产生许多文本框的数字。此代码适用于0,1或2个文本框,但不能添加超过2:

           `int seriuzunlugu;
            seriuzunlugu=Convert.ToInt32(SeriUzunluguTxt.Text);
            int Xtop, Xleft, Ytop, Yleft;
            Xtop = 10;
            Xleft = 70;
            Ytop = 10;
            Yleft = 250;
            for (int i = 0; i <seriuzunlugu ; i++)
            {
                //Xi değeri
                TextBox Xi = new TextBox();
                Xi.Name = "X" + i.ToString();
                Xi.Width = 5;
                Xi.Height = 5;
                canvas.Children.Add(Xi);
                Canvas.SetLeft(Xi,Xleft);
                Canvas.SetTop(Xi,Xtop);
                Xtop = +60;

                //Yi değeri
                TextBox Yi = new TextBox();
                Yi.Name = "Y" + i.ToString();
                Yi.Width = 5;
                Yi.Height = 5;
                canvas.Children.Add(Yi);
                Canvas.SetLeft(Yi, Yleft);
                Canvas.SetTop(Yi, Ytop);
                Ytop = +60;
            }


            //X değeri
            TextBox x = new TextBox();
            x.Name = "xdegeri";
            x.Width = 50;
            x.Height = 10;
            x.Text = canvas.Children.Count.ToString();
            canvas.Children.Add(x);
            Canvas.SetTop(x, Xtop + 50);
            Canvas.SetLeft(x, Xleft);`

0 个答案:

没有答案