wpf自定义控件的位置与window完全不一样啊。。。。。。。。。。。真搞骚。
winform自定义控件位置通过location 如:Button button =new Button(); button.location=new point(x,y);
而wpf的控件自定义位置相对于window来说较为复杂一点。首先将<Grid> 标签变成<Canvas>
然后通过
Button button2 = new Button();
button2.Height = this.Height / 20;
button2.Width = this.Width / 20;
button2.Content = "button2";
button2.SetValue(Canvas.LeftProperty, (double)this.Width * 10 / 16);
button2.Height = this.Height / 20;
button2.Width = this.Width / 20;
button2.Content = "button2";
button2.SetValue(Canvas.LeftProperty, (double)this.Width * 10 / 16);
button2.SetValue(Canvas.TopProperty, this.Height * 9 / 10);